Commit 2f075f60 by xia-chu

修复编译警告,格式化代码

parent 4bd3fdab
......@@ -16,7 +16,7 @@ using namespace std;
using namespace toolkit;
using namespace mediakit;
class MediaHelper : public MediaSourceEvent , public std::enable_shared_from_this<MediaHelper> {
class MediaHelper: public MediaSourceEvent, public std::enable_shared_from_this<MediaHelper> {
public:
using Ptr = std::shared_ptr<MediaHelper>;
MediaHelper(const char *vhost, const char *app, const char *stream, float duration, const ProtocolOption &option) {
......@@ -27,20 +27,16 @@ public:
~MediaHelper() = default;
void attachEvent(){
_channel->setMediaListener(shared_from_this());
}
void attachEvent() { _channel->setMediaListener(shared_from_this()); }
DevChannel::Ptr &getChannel(){
return _channel;
}
DevChannel::Ptr &getChannel() { return _channel; }
void setOnClose(on_mk_media_close cb, std::shared_ptr<void> user_data){
void setOnClose(on_mk_media_close cb, std::shared_ptr<void> user_data) {
_on_close = cb;
_on_close_data = std::move(user_data);
}
void setOnSeek(on_mk_media_seek cb, std::shared_ptr<void> user_data){
void setOnSeek(on_mk_media_seek cb, std::shared_ptr<void> user_data) {
_on_seek = cb;
_on_seek_data = std::move(user_data);
}
......@@ -55,7 +51,7 @@ public:
_on_speed_data = std::move(user_data);
}
void setOnRegist(on_mk_media_source_regist cb, std::shared_ptr<void> user_data){
void setOnRegist(on_mk_media_source_regist cb, std::shared_ptr<void> user_data) {
_on_regist = cb;
_on_regist_data = std::move(user_data);
}
......@@ -97,15 +93,13 @@ protected:
return _on_speed(_on_speed_data.get(), speed);
}
void onRegist(MediaSource &sender, bool regist) override{
void onRegist(MediaSource &sender, bool regist) override {
if (_on_regist) {
_on_regist(_on_regist_data.get(), (mk_media_source)&sender, regist);
}
}
toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) {
return _poller;
}
toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) override { return _poller; }
private:
EventPoller::Ptr _poller;
......@@ -122,7 +116,7 @@ private:
std::shared_ptr<void> _on_regist_data;
};
API_EXPORT void API_CALL mk_media_set_on_close(mk_media ctx, on_mk_media_close cb, void *user_data){
API_EXPORT void API_CALL mk_media_set_on_close(mk_media ctx, on_mk_media_close cb, void *user_data) {
mk_media_set_on_close2(ctx, cb, user_data, nullptr);
}
......@@ -159,14 +153,14 @@ API_EXPORT void API_CALL mk_media_set_on_speed(mk_media ctx, on_mk_media_speed c
mk_media_set_on_speed2(ctx, cb, user_data, nullptr);
}
API_EXPORT void API_CALL mk_media_set_on_speed2(mk_media ctx, on_mk_media_speed cb, void *user_data, on_user_data_free user_data_free){
API_EXPORT void API_CALL mk_media_set_on_speed2(mk_media ctx, on_mk_media_speed cb, void *user_data, on_user_data_free user_data_free) {
assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
std::shared_ptr<void> ptr(user_data, user_data_free ? user_data_free : [](void *) {});
(*obj)->setOnSpeed(cb, std::move(ptr));
}
API_EXPORT void API_CALL mk_media_set_on_regist(mk_media ctx, on_mk_media_source_regist cb, void *user_data){
API_EXPORT void API_CALL mk_media_set_on_regist(mk_media ctx, on_mk_media_source_regist cb, void *user_data) {
mk_media_set_on_regist2(ctx, cb, user_data, nullptr);
}
......@@ -177,7 +171,7 @@ API_EXPORT void API_CALL mk_media_set_on_regist2(mk_media ctx, on_mk_media_sourc
(*obj)->setOnRegist(cb, std::move(ptr));
}
API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx){
API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx) {
assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
return (*obj)->getChannel()->totalReaderCount();
......@@ -209,7 +203,7 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx) {
delete obj;
}
API_EXPORT int API_CALL mk_media_init_video(mk_media ctx, int codec_id, int width, int height, float fps, int bit_rate){
API_EXPORT int API_CALL mk_media_init_video(mk_media ctx, int codec_id, int width, int height, float fps, int bit_rate) {
assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
VideoInfo info;
......@@ -221,7 +215,7 @@ API_EXPORT int API_CALL mk_media_init_video(mk_media ctx, int codec_id, int widt
return (*obj)->getChannel()->initVideo(info);
}
API_EXPORT int API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int sample_rate, int channels, int sample_bit){
API_EXPORT int API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int sample_rate, int channels, int sample_bit) {
assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
AudioInfo info;
......@@ -232,19 +226,19 @@ API_EXPORT int API_CALL mk_media_init_audio(mk_media ctx, int codec_id, int samp
return (*obj)->getChannel()->initAudio(info);
}
API_EXPORT void API_CALL mk_media_init_track(mk_media ctx, mk_track track){
API_EXPORT void API_CALL mk_media_init_track(mk_media ctx, mk_track track) {
assert(ctx && track);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
(*obj)->getChannel()->addTrack(*((Track::Ptr *) track));
}
API_EXPORT void API_CALL mk_media_init_complete(mk_media ctx){
API_EXPORT void API_CALL mk_media_init_complete(mk_media ctx) {
assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
(*obj)->getChannel()->addTrackCompleted();
}
API_EXPORT int API_CALL mk_media_input_frame(mk_media ctx, mk_frame frame){
API_EXPORT int API_CALL mk_media_input_frame(mk_media ctx, mk_frame frame) {
assert(ctx && frame);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
return (*obj)->getChannel()->inputFrame(*((Frame::Ptr *) frame));
......@@ -274,13 +268,13 @@ API_EXPORT int API_CALL mk_media_input_aac(mk_media ctx, const void *data, int l
return (*obj)->getChannel()->inputAAC((const char *) data, len, dts, (char *) adts);
}
API_EXPORT int API_CALL mk_media_input_pcm(mk_media ctx, void *data , int len, uint64_t pts){
API_EXPORT int API_CALL mk_media_input_pcm(mk_media ctx, void *data, int len, uint64_t pts) {
assert(ctx && data && len > 0);
MediaHelper::Ptr* obj = (MediaHelper::Ptr*) ctx;
return (*obj)->getChannel()->inputPCM((char*)data, len, pts);
}
API_EXPORT int API_CALL mk_media_input_audio(mk_media ctx, const void* data, int len, uint64_t dts){
API_EXPORT int API_CALL mk_media_input_audio(mk_media ctx, const void *data, int len, uint64_t dts) {
assert(ctx && data && len > 0);
MediaHelper::Ptr* obj = (MediaHelper::Ptr*) ctx;
return (*obj)->getChannel()->inputAudio((const char*)data, len, dts);
......@@ -290,7 +284,8 @@ API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_u
mk_media_start_send_rtp2(ctx, dst_url, dst_port, ssrc, is_udp, cb, user_data, nullptr);
}
API_EXPORT void API_CALL mk_media_start_send_rtp2(mk_media ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int is_udp, on_mk_media_send_rtp_result cb, void *user_data, on_user_data_free user_data_free){
API_EXPORT void API_CALL mk_media_start_send_rtp2(mk_media ctx, const char *dst_url, uint16_t dst_port, const char *ssrc, int is_udp, on_mk_media_send_rtp_result cb, void *user_data,
on_user_data_free user_data_free) {
assert(ctx && dst_url && ssrc);
MediaHelper::Ptr* obj = (MediaHelper::Ptr*) ctx;
......@@ -312,7 +307,7 @@ API_EXPORT void API_CALL mk_media_start_send_rtp2(mk_media ctx, const char *dst_
});
}
API_EXPORT void API_CALL mk_media_stop_send_rtp(mk_media ctx, const char *ssrc){
API_EXPORT void API_CALL mk_media_stop_send_rtp(mk_media ctx, const char *ssrc) {
assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *)ctx;
// sender参数无用
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论