blob: df2ab9be4ed457bb43ebe60244c388cc62d264b9 [file] [log] [blame]
mflodmancfc8e3b2016-05-03 21:22:04 -07001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef VIDEO_VIDEO_STREAM_DECODER_H_
12#define VIDEO_VIDEO_STREAM_DECODER_H_
mflodmancfc8e3b2016-05-03 21:22:04 -070013
14#include <list>
15#include <map>
16#include <memory>
17#include <vector>
18
Niels Möllerc6ce9c52018-05-11 11:15:30 +020019#include "api/video/video_sink_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
21#include "modules/video_coding/include/video_coding_defines.h"
22#include "rtc_base/criticalsection.h"
23#include "rtc_base/platform_thread.h"
24#include "rtc_base/scoped_ref_ptr.h"
mflodmancfc8e3b2016-05-03 21:22:04 -070025
26namespace webrtc {
27
mflodmancfc8e3b2016-05-03 21:22:04 -070028class ReceiveStatisticsProxy;
mflodmancfc8e3b2016-05-03 21:22:04 -070029
30namespace vcm {
31class VideoReceiver;
32} // namespace vcm
33
34enum StreamType {
35 kViEStreamTypeNormal = 0, // Normal media stream
36 kViEStreamTypeRtx = 1 // Retransmission media stream
37};
38
39class VideoStreamDecoder : public VCMReceiveCallback,
Tommi81de14f2018-03-25 22:19:25 +020040 public VCMReceiveStatisticsCallback {
mflodmancfc8e3b2016-05-03 21:22:04 -070041 public:
nisse76bc8e82017-02-07 09:37:41 -080042 VideoStreamDecoder(
43 vcm::VideoReceiver* video_receiver,
44 VCMFrameTypeCallback* vcm_frame_type_callback,
45 VCMPacketRequestCallback* vcm_packet_request_callback,
46 bool enable_nack,
47 bool enable_fec,
48 ReceiveStatisticsProxy* receive_statistics_proxy,
49 rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream);
Mirko Bonadei8fdcac32018-08-28 16:30:18 +020050 ~VideoStreamDecoder() override;
mflodmancfc8e3b2016-05-03 21:22:04 -070051
52 // Implements VCMReceiveCallback.
sakalcc452e12017-02-09 04:53:45 -080053 int32_t FrameToRender(VideoFrame& video_frame,
Danil Chapovalovb9b146c2018-06-15 12:28:07 +020054 absl::optional<uint8_t> qp,
ilnik00d802b2017-04-11 10:34:31 -070055 VideoContentType content_type) override;
mflodmancfc8e3b2016-05-03 21:22:04 -070056 int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override;
57 void OnIncomingPayloadType(int payload_type) override;
58 void OnDecoderImplementationName(const char* implementation_name) override;
59
60 // Implements VCMReceiveStatisticsCallback.
61 void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override;
62 void OnDiscardedPacketsUpdated(int discarded_packets) override;
63 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override;
ilnik6d5b4d62017-08-30 03:32:14 -070064 void OnCompleteFrame(bool is_keyframe,
65 size_t size_bytes,
66 VideoContentType content_type) override;
philipela45102f2017-02-22 05:30:39 -080067 void OnFrameBufferTimingsUpdated(int decode_ms,
68 int max_decode_ms,
69 int current_delay_ms,
70 int target_delay_ms,
71 int jitter_buffer_ms,
72 int min_playout_delay_ms,
73 int render_delay_ms) override;
mflodmancfc8e3b2016-05-03 21:22:04 -070074
ilnik2edc6842017-07-06 03:06:50 -070075 void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) override;
76
mflodmancfc8e3b2016-05-03 21:22:04 -070077 void RegisterReceiveStatisticsProxy(
78 ReceiveStatisticsProxy* receive_statistics_proxy);
79
Tommi81de14f2018-03-25 22:19:25 +020080 // Called by VideoReceiveStream when stats are updated.
81 void UpdateRtt(int64_t max_rtt_ms);
mflodmancfc8e3b2016-05-03 21:22:04 -070082
83 private:
mflodmancfc8e3b2016-05-03 21:22:04 -070084 // Used for all registered callbacks except rendering.
85 rtc::CriticalSection crit_;
86
87 vcm::VideoReceiver* const video_receiver_;
88
89 ReceiveStatisticsProxy* const receive_stats_callback_;
tommi2e82f382016-06-21 00:26:43 -070090 rtc::VideoSinkInterface<VideoFrame>* const incoming_video_stream_;
mflodmancfc8e3b2016-05-03 21:22:04 -070091};
92
93} // namespace webrtc
94
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020095#endif // VIDEO_VIDEO_STREAM_DECODER_H_