summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2018-07-23 14:26:48 -0700
committerGitHub <noreply@github.com>2018-07-23 14:26:48 -0700
commit6ee1edcfe9bf62fdedfef073337bbb17fb060ad2 (patch)
tree634d4c5b824829c7a9058156709c1342b6cf9885
parentadaf27b0189374f8d0f976de5e68e0af8992ca01 (diff)
parent1f4f032e7a70707e4ce613d5fa42d70a22b20633 (diff)
downloadsdl_core-6ee1edcfe9bf62fdedfef073337bbb17fb060ad2.tar.gz
Merge pull request #2017 from shoamano83/fix/sdl-0139_apt_clarification
Changes for "Clarification of audio format details of AudioPassThru" proposal
-rw-r--r--src/appMain/audio.8bit.wavbin88244 -> 44144 bytes
-rw-r--r--src/components/interfaces/HMI_API.xml29
-rw-r--r--src/components/interfaces/MOBILE_API.xml29
-rw-r--r--src/components/media_manager/src/audio/audio_stream_sender_thread.cc15
-rw-r--r--src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc30
5 files changed, 82 insertions, 21 deletions
diff --git a/src/appMain/audio.8bit.wav b/src/appMain/audio.8bit.wav
index cebf6cc0e2..7a3f970a21 100644
--- a/src/appMain/audio.8bit.wav
+++ b/src/appMain/audio.8bit.wav
Binary files differ
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 18966ff00a..bdbb60f98a 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -1137,21 +1137,35 @@
<enum name="SamplingRate">
<description>Describes different sampling options for PerformAudioPassThru.</description>
- <element name="8KHZ" internal_name="RATE_8KHZ"/>
- <element name="16KHZ" internal_name="RATE_16KHZ"/>
- <element name="22KHZ" internal_name="RATE_22KHZ"/>
- <element name="44KHZ" internal_name="RATE_44KHZ"/>
+ <element name="8KHZ" internal_name="RATE_8KHZ">
+ <description>Sampling rate of 8000 Hz.</description>
+ </element>
+ <element name="16KHZ" internal_name="RATE_16KHZ">
+ <description>Sampling rate of 16000 Hz.</description>
+ </element>
+ <element name="22KHZ" internal_name="RATE_22KHZ">
+ <description>Sampling rate of 22050 Hz.</description>
+ </element>
+ <element name="44KHZ" internal_name="RATE_44KHZ">
+ <description>Sampling rate of 44100 Hz.</description>
+ </element>
</enum>
<enum name="BitsPerSample">
<description>Describes different quality options for PerformAudioPassThru.</description>
- <element name="8_BIT" internal_name="RATE_8_BIT"/>
- <element name="16_BIT" internal_name="RATE_16_BIT"/>
+ <element name="8_BIT" internal_name="RATE_8_BIT">
+ <description>Audio sample is 8 bits wide, unsigned.</description>
+ </element>
+ <element name="16_BIT" internal_name="RATE_16_BIT">
+ <description>Audio sample is 16 bits wide, signed, and in little endian.</description>
+ </element>
</enum>
<enum name="AudioType">
<description>Describes different audio type options for PerformAudioPassThru.</description>
- <element name="PCM" />
+ <element name="PCM">
+ <description>Linear PCM.</description>
+ </element>
</enum>
<enum name="KeyboardLayout">
@@ -2396,6 +2410,7 @@
<description>
Describes different audio type configurations for PerformAudioPassThru.
e.g. 8kHz,8-bit,PCM
+ The audio is recorded in monaural.
</description>
<param name="samplingRate" type="Common.SamplingRate" mandatory="true"/>
<param name="bitsPerSample" type="Common.BitsPerSample" mandatory="true"/>
diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml
index 11c8040722..97bc33ceae 100644
--- a/src/components/interfaces/MOBILE_API.xml
+++ b/src/components/interfaces/MOBILE_API.xml
@@ -480,27 +480,42 @@
<enum name="SamplingRate">
<description>Describes different sampling options for PerformAudioPassThru.</description>
- <element name="8KHZ" internal_name="SamplingRate_8KHZ"/>
- <element name="16KHZ" internal_name="SamplingRate_16KHZ"/>
- <element name="22KHZ" internal_name="SamplingRate_22KHZ"/>
- <element name="44KHZ" internal_name="SamplingRate_44KHZ"/>
+ <element name="8KHZ" internal_name="SamplingRate_8KHZ">
+ <description>Sampling rate of 8000 Hz.</description>
+ </element>
+ <element name="16KHZ" internal_name="SamplingRate_16KHZ">
+ <description>Sampling rate of 16000 Hz.</description>
+ </element>
+ <element name="22KHZ" internal_name="SamplingRate_22KHZ">
+ <description>Sampling rate of 22050 Hz.</description>
+ </element>
+ <element name="44KHZ" internal_name="SamplingRate_44KHZ">
+ <description>Sampling rate of 44100 Hz.</description>
+ </element>
</enum>
<enum name="BitsPerSample">
<description>Describes different quality options for PerformAudioPassThru.</description>
- <element name="8_BIT" internal_name="BitsPerSample_8_BIT"/>
- <element name="16_BIT" internal_name="BitsPerSample_16_BIT"/>
+ <element name="8_BIT" internal_name="BitsPerSample_8_BIT">
+ <description>Audio sample is 8 bits wide, unsigned.</description>
+ </element>
+ <element name="16_BIT" internal_name="BitsPerSample_16_BIT">
+ <description>Audio sample is 16 bits wide, signed, and in little endian.</description>
+ </element>
</enum>
<enum name="AudioType">
<description>Describes different audio type options for PerformAudioPassThru.</description>
- <element name="PCM" />
+ <element name="PCM">
+ <description>Linear PCM.</description>
+ </element>
</enum>
<struct name="AudioPassThruCapabilities">
<description>
Describes different audio type configurations for PerformAudioPassThru.
e.g. {8kHz,8-bit,PCM}
+ The audio is recorded in monaural.
</description>
<param name="samplingRate" type="SamplingRate" mandatory="true"/>
<param name="bitsPerSample" type="BitsPerSample" mandatory="true"/>
diff --git a/src/components/media_manager/src/audio/audio_stream_sender_thread.cc b/src/components/media_manager/src/audio/audio_stream_sender_thread.cc
index e1b932b611..23181e7431 100644
--- a/src/components/media_manager/src/audio/audio_stream_sender_thread.cc
+++ b/src/components/media_manager/src/audio/audio_stream_sender_thread.cc
@@ -61,6 +61,15 @@ const int32_t AudioStreamSenderThread::kAudioPassThruTimeout = 1000;
#endif
const uint32_t kMqueueMessageSize = 4095;
+// Size of RIFF header contained in a .wav file: 12 bytes for 'RIFF' chunk
+// descriptor, 24 bytes for 'fmt ' sub-chunk and 8 bytes for 'data' sub-chunk
+// header.
+// The correct format of audio stream for AudioPassThru feature is to include
+// only audio sample data. Since both pre-recorded file (audio.8bit.wav) and
+// GStreamer-generated file contain RIFF header, we will skip it when reading
+// the files.
+static const uint32_t kRIFFHeaderSize = 44;
+
CREATE_LOGGERPTR_GLOBAL(logger_, "MediaManager")
AudioStreamSenderThread::AudioStreamSenderThread(
@@ -69,7 +78,7 @@ AudioStreamSenderThread::AudioStreamSenderThread(
application_manager::ApplicationManager& app_mngr)
: session_key_(session_key)
, fileName_(fileName)
- , offset_(0)
+ , offset_(kRIFFHeaderSize)
, shouldBeStoped_(false)
, shouldBeStoped_lock_()
, shouldBeStoped_cv_()
@@ -82,7 +91,7 @@ AudioStreamSenderThread::~AudioStreamSenderThread() {}
void AudioStreamSenderThread::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);
- offset_ = 0;
+ offset_ = kRIFFHeaderSize;
while (false == getShouldBeStopped()) {
AutoLock auto_lock(shouldBeStoped_lock_);
@@ -125,7 +134,7 @@ void AudioStreamSenderThread::sendAudioChunkToMobile() {
}
#if !defined(EXTENDED_MEDIA_MODE)
// without recording stream restart reading 1-sec file
- offset_ = 0;
+ offset_ = kRIFFHeaderSize;
#endif
}
diff --git a/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc b/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc
index 99548e71bd..5c12614662 100644
--- a/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc
+++ b/src/components/media_manager/src/audio/from_mic_to_file_recorder_thread.cc
@@ -42,6 +42,9 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "MediaManager")
GMainLoop* FromMicToFileRecorderThread::loop = NULL;
+// As per spec, AudioPassThru recording is in monaural
+static const int kNumAudioChannels = 1;
+
FromMicToFileRecorderThread::FromMicToFileRecorderThread(
const std::string& output_file, int32_t duration)
: threads::ThreadDelegate()
@@ -119,7 +122,8 @@ void FromMicToFileRecorderThread::threadMain() {
initArgs();
GstElement* pipeline;
- GstElement* alsasrc, *wavenc, *filesink;
+ GstElement* alsasrc, *audioconvert, *capsfilter, *wavenc, *filesink;
+ GstCaps* audiocaps;
GstBus* bus;
const gchar* device = "hw:0,0";
@@ -196,11 +200,18 @@ void FromMicToFileRecorderThread::threadMain() {
// Create all of the elements to be added to the pipeline
alsasrc = gst_element_factory_make("alsasrc", "alsasrc0");
+ audioconvert = gst_element_factory_make("audioconvert", "audioconvert0");
+ capsfilter = gst_element_factory_make("capsfilter", "filter0");
wavenc = gst_element_factory_make("wavenc", "wavenc0");
filesink = gst_element_factory_make("filesink", "filesink0");
+ // create a capability to downmix the recorded audio to monaural
+ audiocaps = gst_caps_new_simple(
+ "audio/x-raw", "channels", G_TYPE_INT, kNumAudioChannels, NULL);
+
// Assert that all the elements were created
- if (!alsasrc || !wavenc || !filesink) {
+ if (!alsasrc || !audioconvert || !capsfilter || !wavenc || !filesink ||
+ !audiocaps) {
g_error("Failed creating one or more of the pipeline elements.\n");
}
@@ -209,10 +220,21 @@ void FromMicToFileRecorderThread::threadMain() {
g_object_set(G_OBJECT(filesink), "location", outfile, NULL);
// Add the elements to the pipeline
- gst_bin_add_many(GST_BIN(pipeline), alsasrc, wavenc, filesink, NULL);
+ gst_bin_add_many(GST_BIN(pipeline),
+ alsasrc,
+ audioconvert,
+ capsfilter,
+ wavenc,
+ filesink,
+ NULL);
// Link the elements
- gst_element_link_many(alsasrc, wavenc, filesink, NULL);
+ gst_element_link_many(
+ alsasrc, audioconvert, capsfilter, wavenc, filesink, NULL);
+
+ // set the capability
+ g_object_set(G_OBJECT(capsfilter), "caps", audiocaps, NULL);
+ gst_caps_unref(audiocaps);
gst_element_set_state(pipeline, GST_STATE_PLAYING);