Skip to content

Commit

Permalink
Added support for a data track in SRT Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
dimiden committed Jan 3, 2025
1 parent a611730 commit 189975e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/projects/publishers/srt/srt_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace pub

std::shared_ptr<MediaTrack> first_video_track = nullptr;
std::shared_ptr<MediaTrack> first_audio_track = nullptr;
std::shared_ptr<MediaTrack> first_data_track = nullptr;

for (const auto &[id, track] : GetTracks())
{
Expand All @@ -94,6 +95,10 @@ namespace pub
}
else if (track->GetMediaType() == cmn::MediaType::Data)
{
if (first_data_track == nullptr)
{
first_data_track = track;
}
}
else
{
Expand All @@ -111,7 +116,8 @@ namespace pub
}

bool result = ((first_video_track != nullptr) ? packetizer->AddTrack(first_video_track) : true) &&
((first_audio_track != nullptr) ? packetizer->AddTrack(first_audio_track) : true);
((first_audio_track != nullptr) ? packetizer->AddTrack(first_audio_track) : true) &&
((first_data_track != nullptr) ? packetizer->AddTrack(first_data_track) : true);

if (result == false)
{
Expand Down Expand Up @@ -208,6 +214,11 @@ namespace pub
EnqueuePacket(media_packet);
}

void SrtStream::SendDataFrame(const std::shared_ptr<MediaPacket> &media_packet)
{
EnqueuePacket(media_packet);
}

void SrtStream::BroadcastIfReady(const std::vector<std::shared_ptr<mpegts::Packet>> &packets)
{
std::vector<std::shared_ptr<ov::Data>> data_list;
Expand Down
2 changes: 1 addition & 1 deletion src/projects/publishers/srt/srt_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace pub
//--------------------------------------------------------------------
void SendVideoFrame(const std::shared_ptr<MediaPacket> &media_packet) override;
void SendAudioFrame(const std::shared_ptr<MediaPacket> &media_packet) override;
void SendDataFrame(const std::shared_ptr<MediaPacket> &media_packet) override {} // Not supported yet
void SendDataFrame(const std::shared_ptr<MediaPacket> &media_packet) override;
//--------------------------------------------------------------------

//--------------------------------------------------------------------
Expand Down

0 comments on commit 189975e

Please sign in to comment.