blob: 4f996bdeba6b323c6a8ce119d3486f6bf053bec0 [file] [log] [blame]
mflodmancfc8e3b2016-05-04 04:22:041/*
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 04:47:3111#ifndef VIDEO_VIDEO_STREAM_DECODER_H_
12#define VIDEO_VIDEO_STREAM_DECODER_H_
mflodmancfc8e3b2016-05-04 04:22:0413
14#include <list>
15#include <map>
16#include <memory>
17#include <vector>
18
Mirko Bonadei92ea95e2017-09-15 04:47:3119#include "media/base/videosinkinterface.h"
20#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"
Mirko Bonadei71207422017-09-15 11:58:0925#include "typedefs.h" // NOLINT(build/include)
mflodmancfc8e3b2016-05-04 04:22:0426
27namespace webrtc {
28
29class CallStatsObserver;
30class ChannelStatsObserver;
mflodmancfc8e3b2016-05-04 04:22:0431class EncodedImageCallback;
mflodmancfc8e3b2016-05-04 04:22:0432class ReceiveStatisticsProxy;
33class VideoRenderCallback;
mflodmancfc8e3b2016-05-04 04:22:0434
35namespace vcm {
36class VideoReceiver;
37} // namespace vcm
38
39enum StreamType {
40 kViEStreamTypeNormal = 0, // Normal media stream
41 kViEStreamTypeRtx = 1 // Retransmission media stream
42};
43
44class VideoStreamDecoder : public VCMReceiveCallback,
45 public VCMReceiveStatisticsCallback,
mflodmancfc8e3b2016-05-04 04:22:0446 public CallStatsObserver {
47 public:
48 friend class ChannelStatsObserver;
49
nisse76bc8e82017-02-07 17:37:4150 VideoStreamDecoder(
51 vcm::VideoReceiver* video_receiver,
52 VCMFrameTypeCallback* vcm_frame_type_callback,
53 VCMPacketRequestCallback* vcm_packet_request_callback,
54 bool enable_nack,
55 bool enable_fec,
56 ReceiveStatisticsProxy* receive_statistics_proxy,
57 rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream);
mflodmancfc8e3b2016-05-04 04:22:0458 ~VideoStreamDecoder();
59
60 // Implements VCMReceiveCallback.
sakalcc452e12017-02-09 12:53:4561 int32_t FrameToRender(VideoFrame& video_frame,
ilnik00d802b2017-04-11 17:34:3162 rtc::Optional<uint8_t> qp,
63 VideoContentType content_type) override;
mflodmancfc8e3b2016-05-04 04:22:0464 int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override;
65 void OnIncomingPayloadType(int payload_type) override;
66 void OnDecoderImplementationName(const char* implementation_name) override;
67
68 // Implements VCMReceiveStatisticsCallback.
69 void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override;
70 void OnDiscardedPacketsUpdated(int discarded_packets) override;
71 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override;
ilnik6d5b4d62017-08-30 10:32:1472 void OnCompleteFrame(bool is_keyframe,
73 size_t size_bytes,
74 VideoContentType content_type) override;
philipela45102f2017-02-22 13:30:3975 void OnFrameBufferTimingsUpdated(int decode_ms,
76 int max_decode_ms,
77 int current_delay_ms,
78 int target_delay_ms,
79 int jitter_buffer_ms,
80 int min_playout_delay_ms,
81 int render_delay_ms) override;
mflodmancfc8e3b2016-05-04 04:22:0482
ilnik2edc6842017-07-06 10:06:5083 void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) override;
84
mflodmancfc8e3b2016-05-04 04:22:0485 void RegisterReceiveStatisticsProxy(
86 ReceiveStatisticsProxy* receive_statistics_proxy);
87
88 // Implements StatsObserver.
89 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
90
91 private:
mflodmancfc8e3b2016-05-04 04:22:0492 // Used for all registered callbacks except rendering.
93 rtc::CriticalSection crit_;
94
95 vcm::VideoReceiver* const video_receiver_;
96
97 ReceiveStatisticsProxy* const receive_stats_callback_;
tommi2e82f382016-06-21 07:26:4398 rtc::VideoSinkInterface<VideoFrame>* const incoming_video_stream_;
mflodmancfc8e3b2016-05-04 04:22:0499
danilchapa37de392017-09-09 11:17:22100 int64_t last_rtt_ms_ RTC_GUARDED_BY(crit_);
mflodmancfc8e3b2016-05-04 04:22:04101};
102
103} // namespace webrtc
104
Mirko Bonadei92ea95e2017-09-15 04:47:31105#endif // VIDEO_VIDEO_STREAM_DECODER_H_