Ai
1 Star 9 Fork 9

John Yet/rtsp_proxy_server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
stream_task.cpp 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
learnhow 提交于 2020-07-21 11:31 +08:00 . 初始化第一次提交
#include "stream_task.h"
#include <cstring>
#include "event2/event.h"
#include <iostream>
using namespace std;
using namespace rtsp;
StreamTask::StreamTask()
{
memset(player_host_, 0, 16);
memset(camera_host_, 0, 16);
}
StreamTask *StreamTask::PlayerHost(const char *host)
{
memcpy(player_host_, host, strlen(host));
return this;
}
StreamTask *StreamTask::PlayerPorts(RTSPPort player_rtsp_port, RTSPPort proxy_rtsp_port)
{
player_rtsp_port_ = player_rtsp_port;
player_proxy_rtsp_port_ = proxy_rtsp_port;
return this;
}
StreamTask *StreamTask::CameraHost(const char *host)
{
memcpy(camera_host_, host, strlen(host));
return this;
}
StreamTask *StreamTask::CameraPorts(RTSPPort camera_rtsp_port, RTSPPort proxy_rtsp_port)
{
camera_rtsp_port_ = camera_rtsp_port;
camera_proxy_rtsp_port_ = proxy_rtsp_port;
return this;
}
bool StreamTask::Build(event_base* eb)
{
// 创建rtp管线
rtp_pipe_ = new UDPPipe(player_proxy_rtsp_port_.rtp_port,
camera_proxy_rtsp_port_.rtp_port,
player_host_,
player_rtsp_port_.rtp_port);
rtp_pipe_->set_event_base(eb);
rtp_pipe_->Init();
// 创建rtcp管线
rtcp_pipe_ = new UDPPipe(camera_proxy_rtsp_port_.rtcp_port,
player_proxy_rtsp_port_.rtcp_port,
camera_host_,
camera_rtsp_port_.rtcp_port);
rtcp_pipe_->set_event_base(eb);
rtcp_pipe_->Init();
return true;
}
StreamTask::~StreamTask()
{
if(rtp_pipe_)
{
delete rtp_pipe_;
}
if(rtcp_pipe_)
{
delete rtcp_pipe_;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/learnhow/rtsp_proxy_server.git
git@gitee.com:learnhow/rtsp_proxy_server.git
learnhow
rtsp_proxy_server
rtsp_proxy_server
master

搜索帮助