Media tuple refactor (#3715)

Co-authored-by: cqm <cqm@97kid.com>
This commit is contained in:
mtdxc
2024-07-14 09:32:41 +08:00
committed by GitHub
parent 0eb38635ce
commit d735aa1797
18 changed files with 61 additions and 59 deletions

View File

@@ -224,7 +224,8 @@ int main(int argc, char *argv[]) {
option.enable_mp4 = false;
option.modify_stamp = (int)ProtocolOption::kModifyStampRelative;
//添加拉流代理
auto proxy = std::make_shared<PlayerProxy>(DEFAULT_VHOST, "app", std::to_string(i), option, -1, nullptr, 1);
auto tuple = MediaTuple{DEFAULT_VHOST, "app", std::to_string(i)};
auto proxy = std::make_shared<PlayerProxy>(tuple, option, -1, nullptr, 1);
//开始拉流代理
proxy->play(input_urls[i]);
proxy_map.emplace(i, std::move(proxy));

View File

@@ -137,7 +137,8 @@ int main(int argc, char *argv[]) {
option.enable_mp4 = false;
for (auto i = 0; i < proxy_count; ++i) {
auto stream = to_string(i);
PlayerProxy::Ptr player(new PlayerProxy(DEFAULT_VHOST, "live", stream, option));
auto tuple = MediaTuple{DEFAULT_VHOST, "live", stream, ""};
PlayerProxy::Ptr player(new PlayerProxy(tuple, option));
(*player)[Client::kRtpType] = rtp_type;
player->play(in_url);
proxyMap.emplace(stream, player);

View File

@@ -148,9 +148,10 @@ int main(int argc, char *argv[]) {
MediaSource::Ptr src = nullptr;
PlayerProxy::Ptr proxy = nullptr;;
auto tuple = MediaTuple{DEFAULT_VHOST, app, stream};
if (end_with(in_url, ".mp4")) {
// create MediaSource from mp4file
auto reader = std::make_shared<MP4Reader>(DEFAULT_VHOST, app, stream, in_url);
auto reader = std::make_shared<MP4Reader>(tuple, in_url);
//mp4 repeat
reader->startReadMP4(0, true, true);
src = MediaSource::find(schema, DEFAULT_VHOST, app, stream, false);
@@ -161,7 +162,7 @@ int main(int argc, char *argv[]) {
}
} else {
//添加拉流代理
proxy = std::make_shared<PlayerProxy>(DEFAULT_VHOST, app, stream, option);
proxy = std::make_shared<PlayerProxy>(tuple, option);
//rtsp拉流代理方式
(*proxy)[Client::kRtpType] = rtp_type;
//开始拉流代理

View File

@@ -79,7 +79,8 @@ int domain(const string &playUrl, const string &pushUrl) {
ProtocolOption option;
option.enable_hls = false;
option.enable_mp4 = false;
PlayerProxy::Ptr player(new PlayerProxy(DEFAULT_VHOST, "app", "stream", option, -1, poller));
auto tuple = MediaTuple{DEFAULT_VHOST, "app", "stream", ""};
PlayerProxy::Ptr player(new PlayerProxy(tuple, option, -1, poller));
//可以指定rtsp拉流方式支持tcp和udp方式默认tcp
// (*player)[Client::kRtpType] = Rtsp::RTP_UDP;
player->play(playUrl.data());

View File

@@ -43,7 +43,8 @@ int domain(const string &file, const string &url) {
mINI::Instance()["protocol.enable_" + schema] = 1;
// 从mp4文件加载生成MediaSource对象
auto reader = std::make_shared<MP4Reader>(DEFAULT_VHOST, "live", "stream", file);
auto tuple = MediaTuple {DEFAULT_VHOST, "live", "stream", ""};
auto reader = std::make_shared<MP4Reader>(tuple, file);
// 开始加载mp4ref_self设置为false这样reader对象设置为nullptr就能注销了file_repeat可以设置为空这样文件读完了就停止推流了
reader->startReadMP4(100, false, true);
auto src = MediaSource::find(schema, DEFAULT_VHOST, "live", "stream", false);

View File

@@ -230,8 +230,8 @@ int main(int argc,char *argv[]) {
//http://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
//rtsp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
//rtmp://127.0.0.1/record/live/0/2017-04-11/11-09-38.mp4
PlayerProxy::Ptr player(new PlayerProxy(DEFAULT_VHOST, "live", std::string("chn") + to_string(i).data(), ProtocolOption()));
auto tuple = MediaTuple{DEFAULT_VHOST, "live", std::string("chn") + to_string(i).data(), ""};
PlayerProxy::Ptr player(new PlayerProxy(tuple, ProtocolOption()));
//指定RTP over TCP(播放rtsp时有效)
(*player)[Client::kRtpType] = Rtsp::RTP_TCP;
//开始播放,如果播放失败或者播放中止,将会自动重试若干次,重试次数在配置文件中配置,默认一直重试