先将webrtc的代码进行剥离,提取出媒体处理部分,再进行简单的封装成媒体库,主要函数类似如下:
/*音频相关*/
int audio_init();
int audio_deinit();
int audio_create_channel();
int audio_start_send(int channel_id, const char *ip, int port);
int audio_stop_send(int channel_id);
int audio_start_receive(int channel_id, int port);
int audio_stop_receive(int channel_id);
/*视频相关*/
int video_init();
int video_create_channel(int audio_channel_id);
int video_start_camera(int channel_id, const int p_nCameraNum);
int video_start_local_render(int channel_id, int capture_id, void *window);
int video_start_remote_render(int channel_id, void *window);
int video_start_receive(int channel_id, int port);
int video_stop_receive(int channel_id);
int video_start_send(int channel_id, const char *ip, int port);
int video_stop_send(int channel_id);
int video_set_send_codec(int channel_id, int codec_index);
int video_set_recv_codec(int channel_id, int codec_index);
创建一个测试工程,与linphone互通测试效果如下: