diff options
Diffstat (limited to 'pjsip/include')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 24 | ||||
-rw-r--r-- | pjsip/include/pjsua2/media.hpp | 76 |
2 files changed, 96 insertions, 4 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 00699962..895d9bd8 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -6071,6 +6071,29 @@ PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id, pjmedia_port **p_port); /** + * Get additional info about the file player. This operation is not valid + * for playlist. + * + * @param port The file player ID. + * @param info The info. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_player_get_info(pjsua_player_id id, + pjmedia_wav_player_info *info); + + +/** + * Get playback position. This operation is not valid for playlist. + * + * @param id The file player ID. + * + * @return The current playback position, in samples. On error, + * return the error code as negative value. + */ +PJ_DECL(pj_ssize_t) pjsua_player_get_pos(pjsua_player_id id); + +/** * Set playback position. This operation is not valid for playlist. * * @param id The file player ID. @@ -6082,7 +6105,6 @@ PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id, PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, pj_uint32_t samples); - /** * Close the file of playlist, remove the player from the bridge, and free * resources associated with the file player or playlist. diff --git a/pjsip/include/pjsua2/media.hpp b/pjsip/include/pjsua2/media.hpp index 830f09b7..2f3a6855 100644 --- a/pjsip/include/pjsua2/media.hpp +++ b/pjsip/include/pjsua2/media.hpp @@ -314,6 +314,33 @@ private: typedef std::vector<AudioMedia*> AudioMediaVector; /** + * This structure contains additional info about AudioMediaPlayer. + */ +struct AudioMediaPlayerInfo +{ + /** + * Format ID of the payload. + */ + pjmedia_format_id formatId; + + /** + * The number of bits per sample of the file payload. For example, + * the value is 16 for PCM WAV and 8 for Alaw/Ulas WAV files. + */ + unsigned payloadBitsPerSample; + + /** + * The WAV payload size in bytes. + */ + pj_uint32_t sizeBytes; + + /** + * The WAV payload size in samples. + */ + pj_uint32_t sizeSamples; +}; + +/** * Audio Media Player. */ class AudioMediaPlayer : public AudioMedia @@ -354,7 +381,24 @@ public: unsigned options=0) throw(Error); /** - * Set playback position. This operation is not valid for playlist. + * Get additional info about the player. This operation is only valid + * for player. For playlist, Error will be thrown. + * + * @return the info. + */ + AudioMediaPlayerInfo getInfo() const throw(Error); + + /** + * Get current playback position in samples. This operation is not valid + * for playlist. + * + * @return Current playback position, in samples. + */ + pj_uint32_t getPos() const throw(Error); + + /** + * Set playback position in samples. This operation is not valid for + * playlist. * * @param samples The desired playback position, in samples. */ @@ -371,16 +415,42 @@ public: static AudioMediaPlayer* typecastFromAudioMedia(AudioMedia *media); /** - * Virtual destructor. + * Destructor. */ virtual ~AudioMediaPlayer(); +public: + /* + * Callbacks + */ + + /** + * Register a callback to be called when the file player reading has + * reached the end of file, or when the file reading has reached the + * end of file of the last file for a playlist. If the file or playlist + * is set to play repeatedly, then the callback will be called multiple + * times. + * + * @return If the callback returns false, the playback + * will stop. Note that if application destroys + * the player in the callback, it must return + * false here. + */ + virtual bool onEof() + { return true; } + + private: /** * Player Id. */ int playerId; + /** + * Low level PJMEDIA callback + */ + static pj_status_t eof_cb(pjmedia_port *port, + void *usr_data); }; /** @@ -430,7 +500,7 @@ public: static AudioMediaRecorder* typecastFromAudioMedia(AudioMedia *media); /** - * Virtual destructor. + * Destructor. */ virtual ~AudioMediaRecorder(); |