2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-10 12:13:12 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef VIDEO_VIDEO_STREAM_DECODER_H_
|
|
|
|
|
#define VIDEO_VIDEO_STREAM_DECODER_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-10-13 15:19:55 +00:00
|
|
|
#include <list>
|
2015-11-26 15:24:52 +01:00
|
|
|
#include <map>
|
2016-03-01 11:52:33 -08:00
|
|
|
#include <memory>
|
2015-11-26 15:24:52 +01:00
|
|
|
#include <vector>
|
2011-10-13 15:19:55 +00:00
|
|
|
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2018-05-11 11:15:30 +02:00
|
|
|
#include "api/video/video_sink_interface.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
|
|
|
|
#include "modules/video_coding/include/video_coding_defines.h"
|
|
|
|
|
#include "rtc_base/platform_thread.h"
|
2020-07-08 13:13:32 +02:00
|
|
|
#include "rtc_base/synchronization/mutex.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-15 15:23:08 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-12-18 13:50:16 +00:00
|
|
|
class ReceiveStatisticsProxy;
|
2019-09-09 12:51:55 +02:00
|
|
|
class VideoReceiver2;
|
2016-04-22 18:23:15 +02:00
|
|
|
|
2019-03-25 15:51:03 +01:00
|
|
|
class VideoStreamDecoder : public VCMReceiveCallback {
|
2011-12-15 15:23:08 +00:00
|
|
|
public:
|
2017-02-07 09:37:41 -08:00
|
|
|
VideoStreamDecoder(
|
2019-09-09 12:51:55 +02:00
|
|
|
VideoReceiver2* video_receiver,
|
2017-02-07 09:37:41 -08:00
|
|
|
ReceiveStatisticsProxy* receive_statistics_proxy,
|
|
|
|
|
rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream);
|
2018-08-28 16:30:18 +02:00
|
|
|
~VideoStreamDecoder() override;
|
2012-11-26 12:40:15 +00:00
|
|
|
|
2011-12-15 15:23:08 +00:00
|
|
|
// Implements VCMReceiveCallback.
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
int32_t FrameToRender(VideoFrame& video_frame,
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<uint8_t> qp,
|
2019-07-01 10:07:50 +02:00
|
|
|
int32_t decode_time_ms,
|
2017-04-11 10:34:31 -07:00
|
|
|
VideoContentType content_type) override;
|
2019-08-26 15:04:43 +02:00
|
|
|
void OnDroppedFrames(uint32_t frames_dropped) override;
|
2015-08-28 07:35:32 -07:00
|
|
|
void OnIncomingPayloadType(int payload_type) override;
|
2015-12-18 16:01:11 +01:00
|
|
|
void OnDecoderImplementationName(const char* implementation_name) override;
|
2013-08-12 14:20:49 +00:00
|
|
|
|
2014-12-18 13:50:16 +00:00
|
|
|
void RegisterReceiveStatisticsProxy(
|
|
|
|
|
ReceiveStatisticsProxy* receive_statistics_proxy);
|
2014-03-24 20:28:11 +00:00
|
|
|
|
2011-12-15 15:23:08 +00:00
|
|
|
private:
|
|
|
|
|
// Used for all registered callbacks except rendering.
|
2020-07-08 13:13:32 +02:00
|
|
|
Mutex mutex_;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2019-09-09 12:51:55 +02:00
|
|
|
VideoReceiver2* const video_receiver_;
|
2012-11-26 12:40:15 +00:00
|
|
|
|
2016-05-03 21:22:04 -07:00
|
|
|
ReceiveStatisticsProxy* const receive_stats_callback_;
|
Reland of Split IncomingVideoStream into two implementations, with smoothing and without. (patchset #1 id:1 of https://codereview.webrtc.org/2084873002/ )
Reason for revert:
Reverting the revert. This change is not related to the failure on the Windows FYI bots. The cause of the failure has been reverted in Chromium:
https://codereview.chromium.org/2081653004/
Original issue's description:
> Revert of Split IncomingVideoStream into two implementations, with smoothing and without. (patchset #5 id:340001 of https://codereview.webrtc.org/2078873002/ )
>
> Reason for revert:
> Breaks chromium.webrtc.fyi
>
> https://uberchromegw.corp.google.com/i/chromium.webrtc.fyi/builders/Win7%20Tester/builds/4719
> https://uberchromegw.corp.google.com/i/chromium.webrtc.fyi/builders/Win10%20Tester/builds/3120
>
> Original issue's description:
> > Reland of IncomingVideoStream refactoring.
> > This reland does not contain the non-smoothing part of the original implementation. Instead, when smoothing is turned off, frame callbacks run on the decoder thread, as they did before. This code path is used in Chrome. As far as Chrome goes, the difference now is that there won't be an instance of IncomingVideoStream in between the decoder and the callback (i.e. fewer locks). Other than that, no change for Chrome.
> >
> > Original issue's description (with non-smoothing references removed):
> >
> > Split IncomingVideoStream into two implementations, with smoothing and without.
> >
> > * Added TODOs and documentation for VideoReceiveStream::OnFrame, where we today grab 6 locks.
> >
> > * Removed the Start/Stop methods from the IncomingVideoStream implementations. Now, when an instance is created, it should be considered to be "running" and when it is deleted, it's "not running". This saves on resources and also reduces the amount of locking required and I could remove one critical section altogether.
> >
> > * Changed the VideoStreamDecoder class to not depend on IncomingVideoStream but rather use the generic rtc::VideoSinkInterface<VideoFrame> interface. This means that any implementation of that interface can be used and the decoder can be made to just use the 'renderer' from the config. Once we do that, we can decouple the IncomingVideoStream implementations from the decoder and VideoReceiveStream implementations and leave it up to the application for how to do smoothing. The app can choose to use the Incoming* classes or roll its own (which may be preferable since applications often have their own scheduling mechanisms).
> >
> > * The lifetime of the VideoStreamDecoder instance is now bound to Start/Stop in VideoReceiveStream and not all of the lifetime of VideoReceiveStream.
> >
> > * Fixed VideoStreamDecoder to unregister callbacks in the dtor that were registered in the ctor. (this was open to a use-after-free regression)
> >
> > * Delay and callback pointers are now passed via the ctors to the IncomingVideoStream classes. The thread primitives in the IncomingVideoStream classes are also constructed/destructed at the same time as the owning object, which allowed me to remove one more lock.
> >
> > * Removed code in the VideoStreamDecoder that could overwrite the VideoReceiveStream render delay with a fixed value of 10ms on construction. This wasn't a problem with the previous implementation (it would be now though) but seemed to me like the wrong place to be setting that value.
> >
> > * Made the render delay value in VideoRenderFrames, const.
> >
> > BUG=chromium:620232
> > R=mflodman@webrtc.org, nisse@webrtc.org
> >
> > Committed: https://crrev.com/884c336c345d988974c2a69cea402b0fb8b07a63
> > Cr-Commit-Position: refs/heads/master@{#13219}
>
> TBR=nisse@webrtc.org,philipel@webrtc.org,mflodman@webrtc.org,tommi@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=chromium:620232
>
> Committed: https://crrev.com/a536bfe70de38fe877245317a7f0b00bcf69cbd0
> Cr-Commit-Position: refs/heads/master@{#13229}
TBR=nisse@webrtc.org,philipel@webrtc.org,mflodman@webrtc.org,sakal@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:620232
Review-Url: https://codereview.webrtc.org/2089613002
Cr-Commit-Position: refs/heads/master@{#13230}
2016-06-21 00:26:43 -07:00
|
|
|
rtc::VideoSinkInterface<VideoFrame>* const incoming_video_stream_;
|
2011-12-15 15:23:08 +00:00
|
|
|
};
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-12-15 15:23:08 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // VIDEO_VIDEO_STREAM_DECODER_H_
|