blob: ad355570b65346a70324d67e17a6a00fb1f3e004 [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
11#ifndef WEBRTC_VIDEO_VIDEO_STREAM_DECODER_H_
12#define WEBRTC_VIDEO_VIDEO_STREAM_DECODER_H_
13
14#include <list>
15#include <map>
16#include <memory>
17#include <vector>
18
19#include "webrtc/base/criticalsection.h"
20#include "webrtc/base/platform_thread.h"
21#include "webrtc/base/scoped_ref_ptr.h"
tommi2e82f382016-06-21 00:26:43 -070022#include "webrtc/media/base/videosinkinterface.h"
mflodmancfc8e3b2016-05-03 21:22:04 -070023#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
24#include "webrtc/modules/video_coding/include/video_coding_defines.h"
mflodmancfc8e3b2016-05-03 21:22:04 -070025#include "webrtc/typedefs.h"
mflodmancfc8e3b2016-05-03 21:22:04 -070026
27namespace webrtc {
28
29class CallStatsObserver;
30class ChannelStatsObserver;
mflodmancfc8e3b2016-05-03 21:22:04 -070031class EncodedImageCallback;
32class I420FrameCallback;
mflodmancfc8e3b2016-05-03 21:22:04 -070033class ReceiveStatisticsProxy;
34class VideoRenderCallback;
mflodmancfc8e3b2016-05-03 21:22:04 -070035
36namespace vcm {
37class VideoReceiver;
38} // namespace vcm
39
40enum StreamType {
41 kViEStreamTypeNormal = 0, // Normal media stream
42 kViEStreamTypeRtx = 1 // Retransmission media stream
43};
44
45class VideoStreamDecoder : public VCMReceiveCallback,
46 public VCMReceiveStatisticsCallback,
47 public VCMDecoderTimingCallback,
48 public CallStatsObserver {
49 public:
50 friend class ChannelStatsObserver;
51
52 VideoStreamDecoder(vcm::VideoReceiver* video_receiver,
53 VCMFrameTypeCallback* vcm_frame_type_callback,
54 VCMPacketRequestCallback* vcm_packet_request_callback,
55 bool enable_nack,
mflodmandc7d0d22016-05-06 05:32:22 -070056 bool enable_fec,
mflodmancfc8e3b2016-05-03 21:22:04 -070057 ReceiveStatisticsProxy* receive_statistics_proxy,
tommi2e82f382016-06-21 00:26:43 -070058 rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream,
mflodmancfc8e3b2016-05-03 21:22:04 -070059 I420FrameCallback* pre_render_callback);
60 ~VideoStreamDecoder();
61
62 // Implements VCMReceiveCallback.
63 int32_t FrameToRender(VideoFrame& video_frame) override; // NOLINT
64 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;
72
73 // Implements VCMDecoderTimingCallback.
74 void OnDecoderTiming(int decode_ms,
75 int max_decode_ms,
76 int current_delay_ms,
77 int target_delay_ms,
78 int jitter_buffer_ms,
79 int min_playout_delay_ms,
80 int render_delay_ms) override;
81
mflodmancfc8e3b2016-05-03 21:22:04 -070082 void RegisterReceiveStatisticsProxy(
83 ReceiveStatisticsProxy* receive_statistics_proxy);
84
85 // Implements StatsObserver.
86 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
87
88 private:
mflodmancfc8e3b2016-05-03 21:22:04 -070089 // Used for all registered callbacks except rendering.
90 rtc::CriticalSection crit_;
91
92 vcm::VideoReceiver* const video_receiver_;
93
94 ReceiveStatisticsProxy* const receive_stats_callback_;
tommi2e82f382016-06-21 00:26:43 -070095 rtc::VideoSinkInterface<VideoFrame>* const incoming_video_stream_;
mflodmancfc8e3b2016-05-03 21:22:04 -070096
tommi2e82f382016-06-21 00:26:43 -070097 // TODO(tommi): This callback is basically the same thing as the one above.
98 // We shouldn't need to support both.
mflodmancfc8e3b2016-05-03 21:22:04 -070099 I420FrameCallback* const pre_render_callback_;
100
101 int64_t last_rtt_ms_ GUARDED_BY(crit_);
102};
103
104} // namespace webrtc
105
106#endif // WEBRTC_VIDEO_VIDEO_STREAM_DECODER_H_