12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /*
- * media_player.h
- *
- * Created on: 2022年5月26日
- * Author: pengzc
- */
- #ifndef JNI_VOIP_MEDIA_PLAYER_H_
- #define JNI_VOIP_MEDIA_PLAYER_H_
- #include "audio_player.h"
- namespace base {
- class MediaPlayer {
- public:
- typedef void (*CompletionCallback)(MediaPlayer* player,
- int what, void* user_data);
- typedef void (*ErrorCallback)(MediaPlayer* player,
- int what, const std::string& str, void* user_data);
- typedef int (*AudioCallback)(MediaPlayer* player,
- uint8_t* data, int length, void* user_data);
- MediaPlayer();
- virtual ~MediaPlayer();
- int Play(const std::string& url);
- /**
- *
- * @param url 文件或者链接
- * @param headers 指定HTTP协议的Header字段
- * 例如
- * IP直连,绕过DNS, headers 指定Host字段
- * Host: download.flythings.cn
- *
- * @param timeout_millis 读取超时时间,默认5000毫秒
- * @return 成功返回0
- */
- int Play(const std::string& url, const std::string& headers, int timeout_millis);
- int Pause();
- int Resume();
- int Stop();
- /**
- * 当前播放位置
- */
- double GetCurrentPositon();
- /**
- * 总时长
- */
- double GetDuration();
- void SetErrorCallback(MediaPlayer::ErrorCallback callback, void* user_data);
- void SetCompletionCallback(MediaPlayer::CompletionCallback callback, void* user_data);
- void SetAudioCallback(MediaPlayer::AudioCallback callback, void* user_data);
- /**
- * 设置视频区域
- */
- void SetVideoRectangle(int x, int y, int w, int h);
- private:
- class Impl;
- Impl* impl_;
- };
- } /* namespace base */
- #endif /* JNI_VOIP_MEDIA_PLAYER_H_ */
|