Skip to content

Commit

Permalink
remove useless class
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Jul 13, 2024
1 parent 5dddc17 commit d22e80e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 39 deletions.
23 changes: 0 additions & 23 deletions inc/VideoDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,26 +314,3 @@ class VideoDecoder : public rtc::VideoSourceInterface<webrtc::VideoFrame>, publi
int64_t m_prevts;

};

class VideoSourceWithDecoder : public rtc::VideoSourceInterface<webrtc::VideoFrame>
{
public:
VideoSourceWithDecoder(const std::map<std::string,std::string> & opts, std::unique_ptr<webrtc::VideoDecoderFactory>& videoDecoderFactory, bool wait = false): m_decoder(opts, videoDecoderFactory, wait) {}

// overide rtc::VideoSourceInterface<webrtc::VideoFrame>
void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame> *sink, const rtc::VideoSinkWants &wants)
{
m_decoder.AddOrUpdateSink(sink, wants);
}

void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame> *sink)
{
m_decoder.RemoveSink(sink);
}

int width() { return m_decoder.width(); }
int height() { return m_decoder.height(); }

protected:
VideoDecoder m_decoder;
};
28 changes: 14 additions & 14 deletions inc/livevideosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
#include "VideoDecoder.h"

template <typename T>
class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
class LiveVideoSource : public VideoDecoder, public T::Callback
{
public:
LiveVideoSource(const std::string &uri, const std::map<std::string, std::string> &opts, std::unique_ptr<webrtc::VideoDecoderFactory>& videoDecoderFactory, bool wait) :
VideoSourceWithDecoder(opts, videoDecoderFactory, wait),
VideoDecoder(opts, videoDecoderFactory, wait),
m_env(m_stop),
m_liveclient(m_env, this, uri.c_str(), opts, rtc::LogMessage::GetLogToDebug()<=2) {
m_liveclient.start();
Expand Down Expand Up @@ -92,7 +92,7 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
struct timeval presentationTime;
timerclear(&presentationTime);

std::vector<std::vector<uint8_t>> initFrames = m_decoder.getInitFrames(codec, sdp);
std::vector<std::vector<uint8_t>> initFrames = getInitFrames(codec, sdp);
for (auto frame : initFrames)
{
onData(id, frame.data(), frame.size(), presentationTime);
Expand All @@ -118,12 +118,12 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
if (!sps)
{
RTC_LOG(LS_ERROR) << "cannot parse sps";
m_decoder.postFormat(codec, 0, 0);
postFormat(codec, 0, 0);
}
else
{
RTC_LOG(LS_INFO) << "LiveVideoSource:onData SPS set format " << sps->width << "x" << sps->height;
m_decoder.postFormat(codec, sps->width, sps->height);
postFormat(codec, sps->width, sps->height);
}
}
else if (nalu_type == webrtc::H264::NaluType::kPps)
Expand All @@ -148,14 +148,14 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
{
RTC_LOG(LS_VERBOSE) << "LiveVideoSource:onData SLICE NALU:" << nalu_type;
}
if (m_prevTimestamp && ts < m_prevTimestamp && m_decoder.m_decoder && strcmp(m_decoder.m_decoder->ImplementationName(),"FFmpeg")==0)
if (m_prevTimestamp && ts < m_prevTimestamp && m_decoder && strcmp(m_decoder->ImplementationName(),"FFmpeg")==0)
{
RTC_LOG(LS_ERROR) << "LiveVideoSource:onData drop frame in past for FFmpeg:" << (m_prevTimestamp-ts);

} else {
content.insert(content.end(), buffer + index.start_offset, buffer + index.payload_size + index.payload_start_offset);
rtc::scoped_refptr<webrtc::EncodedImageBuffer> frame = webrtc::EncodedImageBuffer::Create(content.data(), content.size());
m_decoder.PostFrame(frame, ts, frameType);
PostFrame(frame, ts, frameType);
}
}
}
Expand All @@ -182,12 +182,12 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
if (!sps)
{
RTC_LOG(LS_ERROR) << "cannot parse sps";
m_decoder.postFormat(codec, 0, 0);
postFormat(codec, 0, 0);
}
else
{
RTC_LOG(LS_INFO) << "LiveVideoSource:onData SPS set format " << sps->width << "x" << sps->height;
m_decoder.postFormat(codec, sps->width, sps->height);
postFormat(codec, sps->width, sps->height);
}
}
else if (nalu_type == webrtc::H265::NaluType::kPps)
Expand All @@ -209,14 +209,14 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
{
RTC_LOG(LS_VERBOSE) << "LiveVideoSource:onData SLICE NALU:" << nalu_type;
}
if (m_prevTimestamp && ts < m_prevTimestamp && m_decoder.m_decoder && strcmp(m_decoder.m_decoder->ImplementationName(),"FFmpeg")==0)
if (m_prevTimestamp && ts < m_prevTimestamp && m_decoder && strcmp(m_decoder->ImplementationName(),"FFmpeg")==0)
{
RTC_LOG(LS_ERROR) << "LiveVideoSource:onData drop frame in past for FFmpeg:" << (m_prevTimestamp-ts);

} else {
content.insert(content.end(), buffer + index.start_offset, buffer + index.payload_size + index.payload_start_offset);
rtc::scoped_refptr<webrtc::EncodedImageBuffer> frame = webrtc::EncodedImageBuffer::Create(content.data(), content.size());
m_decoder.PostFrame(frame, ts, frameType);
PostFrame(frame, ts, frameType);
}
}
}
Expand Down Expand Up @@ -249,7 +249,7 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
.set_timestamp_ms(ts)
.set_id(ts)
.build();
m_decoder.Decoded(frame);
Decoded(frame);
}
else
{
Expand Down Expand Up @@ -287,11 +287,11 @@ class LiveVideoSource : public VideoSourceWithDecoder, public T::Callback
}
else if (codec == "VP9")
{
m_decoder.postFormat(codec, 0, 0);
postFormat(codec, 0, 0);

webrtc::VideoFrameType frameType = webrtc::VideoFrameType::kVideoFrameKey;
rtc::scoped_refptr<webrtc::EncodedImageBuffer> frame = webrtc::EncodedImageBuffer::Create(buffer, size);
m_decoder.PostFrame(frame, ts, frameType);
PostFrame(frame, ts, frameType);
}

m_prevTimestamp = ts;
Expand Down
4 changes: 2 additions & 2 deletions inc/rtmpvideosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define CODEC_ID_AVC 7
#define CODEC_ID_HEVC 12

class RtmpVideoSource : public VideoSourceWithDecoder
class RtmpVideoSource : public VideoDecoder
{
public:
static RtmpVideoSource *Create(const std::string &url, const std::map<std::string, std::string> &opts, std::unique_ptr<webrtc::VideoDecoderFactory> &videoDecoderFactory)
Expand All @@ -55,7 +55,7 @@ class RtmpVideoSource : public VideoSourceWithDecoder
RtmpVideoSource(const std::string &uri, const std::map<std::string, std::string> &opts, std::unique_ptr<webrtc::VideoDecoderFactory> &videoDecoderFactory) :
m_stop(false),
m_url(uri),
VideoSourceWithDecoder(opts, videoDecoderFactory)
VideoDecoder(opts, videoDecoderFactory)
{
RTMP_Init(&m_rtmp);
RTMP_LogSetOutput(stderr);
Expand Down

0 comments on commit d22e80e

Please sign in to comment.