ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1 // Copyright 2017 Baidu Inc. All Rights Reserved.
TMBOY 47:9e361da97763 2 // Author: Chen Xihao (chenxihao@baidu.com)
TMBOY 47:9e361da97763 3 //
TMBOY 47:9e361da97763 4 // Description: Media Manager
TMBOY 47:9e361da97763 5
TMBOY 47:9e361da97763 6 #ifndef BAIDU_TINYDU_IOT_OS_SRC_MEDIA_DATA_MANAGER_BAIDU_MEDIA_MANAGER_H
TMBOY 47:9e361da97763 7 #define BAIDU_TINYDU_IOT_OS_SRC_MEDIA_DATA_MANAGER_BAIDU_MEDIA_MANAGER_H
TMBOY 47:9e361da97763 8
TMBOY 47:9e361da97763 9 #include <stddef.h>
TMBOY 47:9e361da97763 10 #include "baidu_media_play_type.h"
TMBOY 47:9e361da97763 11
TMBOY 47:9e361da97763 12 namespace duer {
TMBOY 47:9e361da97763 13
TMBOY 47:9e361da97763 14 class MediaManager {
TMBOY 47:9e361da97763 15 public:
TMBOY 47:9e361da97763 16 static MediaManager& instance();
TMBOY 47:9e361da97763 17
TMBOY 47:9e361da97763 18 /*
TMBOY 47:9e361da97763 19 * Initialize MediaManager object.
TMBOY 47:9e361da97763 20 *
TMBOY 47:9e361da97763 21 * @Return bool, success: true, fail: false
TMBOY 47:9e361da97763 22 */
TMBOY 47:9e361da97763 23 bool initialize();
TMBOY 47:9e361da97763 24
TMBOY 47:9e361da97763 25 /*
TMBOY 47:9e361da97763 26 * Initialize MediaManager object by buffer .
TMBOY 47:9e361da97763 27 *
TMBOY 47:9e361da97763 28 * @Param buffer, buffer for media data
TMBOY 47:9e361da97763 29 * @Param size, size of buffer
TMBOY 47:9e361da97763 30 * @Return bool, success: true, fail: false
TMBOY 47:9e361da97763 31 */
TMBOY 47:9e361da97763 32 bool initialize(void* buffer, size_t size);
TMBOY 47:9e361da97763 33
TMBOY 47:9e361da97763 34 /*
TMBOY 47:9e361da97763 35 * Play network media file
TMBOY 47:9e361da97763 36 *
TMBOY 47:9e361da97763 37 * @Param url, media file's url
TMBOY 47:9e361da97763 38 * @Return MediaPlayerStatus, the last status of media player
TMBOY 47:9e361da97763 39 */
TMBOY 47:9e361da97763 40 MediaPlayerStatus play_url(const char* url);
TMBOY 47:9e361da97763 41
TMBOY 47:9e361da97763 42 /*
TMBOY 47:9e361da97763 43 * Play local media file
TMBOY 47:9e361da97763 44 *
TMBOY 47:9e361da97763 45 * @Param path, media file's path
TMBOY 47:9e361da97763 46 * @Return MediaPlayerStatus, the last status of media player
TMBOY 47:9e361da97763 47 */
TMBOY 47:9e361da97763 48 MediaPlayerStatus play_local(const char* path);
TMBOY 47:9e361da97763 49
TMBOY 47:9e361da97763 50 /*
TMBOY 47:9e361da97763 51 * If media player's status is playing/pause, pause/resume it
TMBOY 47:9e361da97763 52 *
TMBOY 47:9e361da97763 53 * @Return MediaPlayerStatus, the last status of media player
TMBOY 47:9e361da97763 54 */
TMBOY 47:9e361da97763 55 MediaPlayerStatus pause_or_resume();
TMBOY 47:9e361da97763 56
TMBOY 47:9e361da97763 57 /*
TMBOY 47:9e361da97763 58 * Stop media player
TMBOY 47:9e361da97763 59 *
TMBOY 47:9e361da97763 60 * @Return MediaPlayerStatus, the last status of media player
TMBOY 47:9e361da97763 61 */
TMBOY 47:9e361da97763 62 MediaPlayerStatus stop();
TMBOY 47:9e361da97763 63
TMBOY 47:9e361da97763 64 /*
TMBOY 47:9e361da97763 65 * Get status of media player
TMBOY 47:9e361da97763 66 *
TMBOY 47:9e361da97763 67 * @Return MediaPlayerStatus, the current status of media player
TMBOY 47:9e361da97763 68 */
TMBOY 47:9e361da97763 69 MediaPlayerStatus get_media_player_status();
TMBOY 47:9e361da97763 70
TMBOY 47:9e361da97763 71 /*
TMBOY 47:9e361da97763 72 * Register the callback function which is called when media player stop
TMBOY 47:9e361da97763 73 * Can't register more than 5 function
TMBOY 47:9e361da97763 74 *
TMBOY 47:9e361da97763 75 * @Param callback, callback function
TMBOY 47:9e361da97763 76 * @Return int, success: 0, fail: -1
TMBOY 47:9e361da97763 77 */
TMBOY 47:9e361da97763 78 int register_stop_callback(media_player_stop_callback callback);
TMBOY 47:9e361da97763 79
TMBOY 47:9e361da97763 80 /*
TMBOY 47:9e361da97763 81 * Unregister the callback function
TMBOY 47:9e361da97763 82 *
TMBOY 47:9e361da97763 83 * @Param callback, callback function
TMBOY 47:9e361da97763 84 * @Return int, success: 0, fail: -1
TMBOY 47:9e361da97763 85 */
TMBOY 47:9e361da97763 86 int unregister_stop_callback(media_player_stop_callback callback);
TMBOY 47:9e361da97763 87
TMBOY 47:9e361da97763 88 /*
TMBOY 47:9e361da97763 89 * Set volume of audio
TMBOY 47:9e361da97763 90 *
TMBOY 47:9e361da97763 91 * @Param vol, effective range is 0~15
TMBOY 47:9e361da97763 92 */
TMBOY 47:9e361da97763 93 void set_volume(unsigned char vol);
TMBOY 47:9e361da97763 94
TMBOY 47:9e361da97763 95 private:
TMBOY 47:9e361da97763 96 MediaManager();
TMBOY 47:9e361da97763 97
TMBOY 47:9e361da97763 98 static MediaManager _s_instance;
TMBOY 47:9e361da97763 99 static bool _s_initialized;
TMBOY 47:9e361da97763 100 };
TMBOY 47:9e361da97763 101
TMBOY 47:9e361da97763 102 } // namespace duer
TMBOY 47:9e361da97763 103
TMBOY 47:9e361da97763 104 #endif // BAIDU_TINYDU_IOT_OS_SRC_MEDIA_DATA_MANAGER_BAIDU_MEDIA_MANAGER_H