diff options
Diffstat (limited to 'src/components/media_manager/include/media_manager/audio')
8 files changed, 215 insertions, 154 deletions
diff --git a/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h b/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h index 257564e81a..3f262b27bb 100644 --- a/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h +++ b/src/components/media_manager/include/media_manager/audio/a2dp_source_player_adapter.h @@ -38,6 +38,10 @@ #include "media_manager/media_adapter_impl.h" #include "utils/threads/thread_delegate.h" +namespace protocol_handler { +class SessionObserver; +} + namespace threads { class Thread; } @@ -45,22 +49,28 @@ class Thread; namespace media_manager { class A2DPSourcePlayerAdapter : public MediaAdapterImpl { - public: - A2DPSourcePlayerAdapter(); - ~A2DPSourcePlayerAdapter(); - void SendData(int32_t application_key, - const ::protocol_handler::RawMessagePtr message) {} - void StartActivity(int32_t application_key); - void StopActivity(int32_t application_key); - bool is_app_performing_activity(int32_t application_key); + public: + A2DPSourcePlayerAdapter(protocol_handler::SessionObserver& session_observer); + ~A2DPSourcePlayerAdapter(); + void SendData(int32_t application_key, + const ::protocol_handler::RawMessagePtr message) {} + void StartActivity(int32_t application_key); + void StopActivity(int32_t application_key); + bool is_app_performing_activity(int32_t application_key) const; + + void set_connection_handler( + connection_handler::ConnectionHandlerImpl* connection_handler) { + connection_handler_ = connection_handler; + } - private: - class A2DPSourcePlayerThread; + private: + class A2DPSourcePlayerThread; - typedef std::pair<threads::Thread*, A2DPSourcePlayerThread*> Pair; - typedef std::map<int32_t, Pair> SourcesMap; - SourcesMap sources_; - DISALLOW_COPY_AND_ASSIGN(A2DPSourcePlayerAdapter); + typedef std::pair<threads::Thread*, A2DPSourcePlayerThread*> Pair; + typedef std::map<int32_t, Pair> SourcesMap; + SourcesMap sources_; + protocol_handler::SessionObserver& session_observer_; + DISALLOW_COPY_AND_ASSIGN(A2DPSourcePlayerAdapter); }; } // namespace media_manager diff --git a/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h b/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h index cb1c144706..b956f2c9e2 100644 --- a/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h +++ b/src/components/media_manager/include/media_manager/audio/audio_stream_sender_thread.h @@ -39,13 +39,16 @@ #include "utils/conditional_variable.h" #include "utils/lock.h" - namespace NsSmartDeviceLink { namespace NsSmartObjects { class SmartObject; } } +namespace application_manager { +class ApplicationManager; +} + namespace media_manager { typedef enum { @@ -62,68 +65,67 @@ typedef enum { ACQ_16_BIT = 1 } AudioCaptureQuality; -typedef enum { - AT_INVALID = -1, - AT_PCM = 0 -} AudioType; +typedef enum { AT_INVALID = -1, AT_PCM = 0 } AudioType; /* - * @brief AudioStreamSenderThread class used to read binary data written from microphone + * @brief AudioStreamSenderThread class used to read binary data written from + * microphone * and send it every 1 second to mobile device. */ class AudioStreamSenderThread : public threads::ThreadDelegate { - public: - /* - * @brief AudioStreamSenderThread class constructor - * - * @param session_key Session key of connection for Mobile side - * @param correlation_id Correlation id for response for Mobile side - */ - AudioStreamSenderThread(const std::string fileName, - uint32_t session_key); - - /* - * @brief AudioStreamSenderThread class destructor - */ - ~AudioStreamSenderThread(); - - /** - * @brief Thread procedure. - */ - void threadMain(); - - /* - * @brief Retrieve session key - * - * @return Stored session key - */ - uint32_t session_key() const; - - void exitThreadMain(); - - private: - /* - * @brief Sends AudioPassThru request - */ - bool SendEndAudioPassThru(); - - void sendAudioChunkToMobile(); - - - bool getShouldBeStopped(); - void setShouldBeStopped(bool should_stop); - - uint32_t session_key_; - const std::string fileName_; - int32_t offset_; - volatile bool shouldBeStoped_; - sync_primitives::Lock shouldBeStoped_lock_; - sync_primitives::ConditionalVariable shouldBeStoped_cv_; - - static const int32_t kAudioPassThruTimeout; - - - DISALLOW_COPY_AND_ASSIGN(AudioStreamSenderThread); + public: + /* + * @brief AudioStreamSenderThread class constructor + * + * @param session_key Session key of connection for Mobile side + * @param correlation_id Correlation id for response for Mobile side + */ + AudioStreamSenderThread(const std::string& fileName, + uint32_t session_key, + application_manager::ApplicationManager& app_mngr); + + /* + * @brief AudioStreamSenderThread class destructor + */ + ~AudioStreamSenderThread(); + + /** + * @brief Thread procedure. + */ + void threadMain(); + + /* + * @brief Retrieve session key + * + * @return Stored session key + */ + uint32_t session_key() const; + + void exitThreadMain(); + + private: + /* + * @brief Sends AudioPassThru request + */ + bool SendEndAudioPassThru(); + + void sendAudioChunkToMobile(); + + bool getShouldBeStopped(); + void setShouldBeStopped(bool should_stop); + + uint32_t session_key_; + const std::string fileName_; + int32_t offset_; + volatile bool shouldBeStoped_; + sync_primitives::Lock shouldBeStoped_lock_; + sync_primitives::ConditionalVariable shouldBeStoped_cv_; + + static const int32_t kAudioPassThruTimeout; + + application_manager::ApplicationManager& application_manager_; + + DISALLOW_COPY_AND_ASSIGN(AudioStreamSenderThread); }; } // namespace media_manager diff --git a/src/components/media_manager/include/media_manager/audio/file_audio_streamer_adapter.h b/src/components/media_manager/include/media_manager/audio/file_audio_streamer_adapter.h new file mode 100644 index 0000000000..dc0c001acf --- /dev/null +++ b/src/components/media_manager/include/media_manager/audio/file_audio_streamer_adapter.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014-2015, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_FILE_AUDIO_STREAMER_ADAPTER_H_ +#define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_FILE_AUDIO_STREAMER_ADAPTER_H_ + +#include "media_manager/file_streamer_adapter.h" + +namespace media_manager { + +class FileAudioStreamerAdapter : public FileStreamerAdapter { + public: + FileAudioStreamerAdapter(const std::string& audio_stream_file, + const std::string& app_storage_folder); + ~FileAudioStreamerAdapter(); +}; + +} // namespace media_manager + +#endif // SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_FILE_AUDIO_STREAMER_ADAPTER_H_ diff --git a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h index 3ea4581435..7daf9c7add 100644 --- a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h +++ b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_adapter.h @@ -43,22 +43,23 @@ class Thread; namespace media_manager { class FromMicRecorderAdapter : public MediaAdapterImpl { - public: - FromMicRecorderAdapter(); - ~FromMicRecorderAdapter(); - void SendData(int32_t application_key, - const ::protocol_handler::RawMessagePtr message) {} - void StartActivity(int32_t application_key); - void StopActivity(int32_t application_key); - bool is_app_performing_activity(int32_t application_key); - void set_output_file(const std::string& output_file); - void set_duration(int32_t duration); - private: - threads::Thread* recorder_thread_; - std::string output_file_; - const int32_t kDefaultDuration; - int32_t duration_; - DISALLOW_COPY_AND_ASSIGN(FromMicRecorderAdapter); + public: + FromMicRecorderAdapter(); + ~FromMicRecorderAdapter(); + void SendData(int32_t application_key, + const ::protocol_handler::RawMessagePtr message) {} + void StartActivity(int32_t application_key); + void StopActivity(int32_t application_key); + bool is_app_performing_activity(int32_t application_key) const; + void set_output_file(const std::string& output_file); + void set_duration(int32_t duration); + + private: + threads::Thread* recorder_thread_; + std::string output_file_; + const int32_t kDefaultDuration; + int32_t duration_; + DISALLOW_COPY_AND_ASSIGN(FromMicRecorderAdapter); }; } // namespace media_manager diff --git a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h index 7df2af7f4a..c615195f94 100644 --- a/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h +++ b/src/components/media_manager/include/media_manager/audio/from_mic_recorder_listener.h @@ -36,30 +36,33 @@ #include <string> #include "media_manager/media_adapter_listener.h" +namespace application_manager { +class ApplicationManager; +} + namespace threads { class Thread; } namespace media_manager { class FromMicRecorderListener : public MediaAdapterListener { - public: - explicit FromMicRecorderListener( - const std::string& file_name); - ~FromMicRecorderListener(); - virtual void OnDataReceived( - int32_t application_key, - const DataForListener& data); - virtual void OnErrorReceived( - int32_t application_key, - const DataForListener& data); - virtual void OnActivityStarted(int32_t application_key); - virtual void OnActivityEnded(int32_t application_key); + public: + FromMicRecorderListener(const std::string& file_name, + application_manager::ApplicationManager&); + ~FromMicRecorderListener(); + virtual void OnDataReceived(int32_t application_key, + const DataForListener& data); + virtual void OnErrorReceived(int32_t application_key, + const DataForListener& data); + virtual void OnActivityStarted(int32_t application_key); + virtual void OnActivityEnded(int32_t application_key); - private: - threads::Thread* reader_; - std::string file_name_; - int32_t current_application_; - DISALLOW_COPY_AND_ASSIGN(FromMicRecorderListener); + private: + threads::Thread* reader_; + std::string file_name_; + int32_t current_application_; + application_manager::ApplicationManager& application_manager_; + DISALLOW_COPY_AND_ASSIGN(FromMicRecorderListener); }; } // namespace media_manager diff --git a/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h b/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h index 7bb036fa42..f0c6d3c48f 100644 --- a/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h +++ b/src/components/media_manager/include/media_manager/audio/from_mic_to_file_recorder_thread.h @@ -44,53 +44,52 @@ namespace media_manager { class FromMicToFileRecorderThread : public threads::ThreadDelegate { - public: - FromMicToFileRecorderThread(const std::string& output_file, - int32_t duration); - ~FromMicToFileRecorderThread(); - void threadMain(); + public: + FromMicToFileRecorderThread(const std::string& output_file, int32_t duration); + ~FromMicToFileRecorderThread(); + void threadMain(); - void exitThreadMain(); + void exitThreadMain(); - void set_output_file(const std::string& output_file); - void set_record_duration(int32_t duration); + void set_output_file(const std::string& output_file); + void set_record_duration(int32_t duration); - private: - int32_t argc_; - gchar** argv_; + private: + int32_t argc_; + gchar** argv_; - const std::string oKey_; - const std::string tKey_; + const std::string oKey_; + const std::string tKey_; - static GMainLoop* loop; - threads::Thread* sleepThread_; - bool shouldBeStoped_; - sync_primitives::Lock stopFlagLock_; + static GMainLoop* loop; + threads::Thread* sleepThread_; + bool shouldBeStoped_; + sync_primitives::Lock stopFlagLock_; - std::string outputFileName_, durationString_; + std::string outputFileName_, durationString_; - typedef struct { - GstElement* pipeline; - gint duration; - } GstTimeout; + typedef struct { + GstElement* pipeline; + gint duration; + } GstTimeout; - void initArgs(); + void initArgs(); - void psleep(void* timeout); + void psleep(void* timeout); - class SleepThreadDelegate : public threads::ThreadDelegate { - public: - explicit SleepThreadDelegate(GstTimeout timeout); + class SleepThreadDelegate : public threads::ThreadDelegate { + public: + explicit SleepThreadDelegate(GstTimeout timeout); - void threadMain(); + void threadMain(); - private: - GstTimeout timeout_; + private: + GstTimeout timeout_; - DISALLOW_COPY_AND_ASSIGN(SleepThreadDelegate); - }; + DISALLOW_COPY_AND_ASSIGN(SleepThreadDelegate); + }; - DISALLOW_COPY_AND_ASSIGN(FromMicToFileRecorderThread); + DISALLOW_COPY_AND_ASSIGN(FromMicToFileRecorderThread); }; } // namespace media_manager diff --git a/src/components/media_manager/include/media_manager/audio/pipe_audio_streamer_adapter.h b/src/components/media_manager/include/media_manager/audio/pipe_audio_streamer_adapter.h index 437f34fa03..d0dbbebd38 100644 --- a/src/components/media_manager/include/media_manager/audio/pipe_audio_streamer_adapter.h +++ b/src/components/media_manager/include/media_manager/audio/pipe_audio_streamer_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2014-2015, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,17 +33,15 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_PIPE_AUDIO_STREAMER_ADAPTER_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_PIPE_AUDIO_STREAMER_ADAPTER_H_ -#include <string> #include "media_manager/pipe_streamer_adapter.h" namespace media_manager { -class PipeAudioStreamerAdapter : public PipeStreamerAdapter { - public: - PipeAudioStreamerAdapter(); - ~PipeAudioStreamerAdapter(); - private: - DISALLOW_COPY_AND_ASSIGN(PipeAudioStreamerAdapter); +class PipeAudioStreamerAdapter : public PipeStreamerAdapter { + public: + PipeAudioStreamerAdapter(const std::string& named_audio_pipe_path, + const std::string& app_storage_folder); + ~PipeAudioStreamerAdapter(); }; } // namespace media_manager diff --git a/src/components/media_manager/include/media_manager/audio/socket_audio_streamer_adapter.h b/src/components/media_manager/include/media_manager/audio/socket_audio_streamer_adapter.h index be5951be3e..c0f3174496 100644 --- a/src/components/media_manager/include/media_manager/audio/socket_audio_streamer_adapter.h +++ b/src/components/media_manager/include/media_manager/audio/socket_audio_streamer_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2014-2015, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,18 +33,17 @@ #ifndef SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_SOCKET_AUDIO_STREAMER_ADAPTER_H_ #define SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_SOCKET_AUDIO_STREAMER_ADAPTER_H_ -#include <string> #include "media_manager/socket_streamer_adapter.h" namespace media_manager { + class SocketAudioStreamerAdapter : public SocketStreamerAdapter { - public: - SocketAudioStreamerAdapter(); - virtual ~SocketAudioStreamerAdapter(); - private: - DISALLOW_COPY_AND_ASSIGN(SocketAudioStreamerAdapter); + public: + SocketAudioStreamerAdapter(const std::string& server_address, + uint16_t audio_streaming_port); + virtual ~SocketAudioStreamerAdapter(); }; -} // namespace media_manager +} // namespace media_manager #endif // SRC_COMPONENTS_MEDIA_MANAGER_INCLUDE_MEDIA_MANAGER_AUDIO_SOCKET_AUDIO_STREAMER_ADAPTER_H_ |