mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef VIDEO_VIDEO_STREAM_DECODER_H_ |
| 12 | #define VIDEO_VIDEO_STREAM_DECODER_H_ |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 13 | |
| 14 | #include <list> |
| 15 | #include <map> |
| 16 | #include <memory> |
| 17 | #include <vector> |
| 18 | |
Niels Möller | c6ce9c5 | 2018-05-11 11:15:30 +0200 | [diff] [blame^] | 19 | #include "api/video/video_sink_interface.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 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 Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 25 | #include "typedefs.h" // NOLINT(build/include) |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 26 | |
| 27 | namespace webrtc { |
| 28 | |
| 29 | class CallStatsObserver; |
| 30 | class ChannelStatsObserver; |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 31 | class EncodedImageCallback; |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 32 | class ReceiveStatisticsProxy; |
| 33 | class VideoRenderCallback; |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 34 | |
| 35 | namespace vcm { |
| 36 | class VideoReceiver; |
| 37 | } // namespace vcm |
| 38 | |
| 39 | enum StreamType { |
| 40 | kViEStreamTypeNormal = 0, // Normal media stream |
| 41 | kViEStreamTypeRtx = 1 // Retransmission media stream |
| 42 | }; |
| 43 | |
| 44 | class VideoStreamDecoder : public VCMReceiveCallback, |
Tommi | 81de14f | 2018-03-25 22:19:25 +0200 | [diff] [blame] | 45 | public VCMReceiveStatisticsCallback { |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 46 | public: |
| 47 | friend class ChannelStatsObserver; |
| 48 | |
nisse | 76bc8e8 | 2017-02-07 09:37:41 -0800 | [diff] [blame] | 49 | VideoStreamDecoder( |
| 50 | vcm::VideoReceiver* video_receiver, |
| 51 | VCMFrameTypeCallback* vcm_frame_type_callback, |
| 52 | VCMPacketRequestCallback* vcm_packet_request_callback, |
| 53 | bool enable_nack, |
| 54 | bool enable_fec, |
| 55 | ReceiveStatisticsProxy* receive_statistics_proxy, |
| 56 | rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream); |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 57 | ~VideoStreamDecoder(); |
| 58 | |
| 59 | // Implements VCMReceiveCallback. |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 60 | int32_t FrameToRender(VideoFrame& video_frame, |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 61 | rtc::Optional<uint8_t> qp, |
| 62 | VideoContentType content_type) override; |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 63 | int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override; |
| 64 | void OnIncomingPayloadType(int payload_type) override; |
| 65 | void OnDecoderImplementationName(const char* implementation_name) override; |
| 66 | |
| 67 | // Implements VCMReceiveStatisticsCallback. |
| 68 | void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override; |
| 69 | void OnDiscardedPacketsUpdated(int discarded_packets) override; |
| 70 | void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 71 | void OnCompleteFrame(bool is_keyframe, |
| 72 | size_t size_bytes, |
| 73 | VideoContentType content_type) override; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 74 | void OnFrameBufferTimingsUpdated(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; |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 81 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 82 | void OnTimingFrameInfoUpdated(const TimingFrameInfo& info) override; |
| 83 | |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 84 | void RegisterReceiveStatisticsProxy( |
| 85 | ReceiveStatisticsProxy* receive_statistics_proxy); |
| 86 | |
Tommi | 81de14f | 2018-03-25 22:19:25 +0200 | [diff] [blame] | 87 | // Called by VideoReceiveStream when stats are updated. |
| 88 | void UpdateRtt(int64_t max_rtt_ms); |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 89 | |
| 90 | private: |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 91 | // Used for all registered callbacks except rendering. |
| 92 | rtc::CriticalSection crit_; |
| 93 | |
| 94 | vcm::VideoReceiver* const video_receiver_; |
| 95 | |
| 96 | ReceiveStatisticsProxy* const receive_stats_callback_; |
tommi | 2e82f38 | 2016-06-21 00:26:43 -0700 | [diff] [blame] | 97 | rtc::VideoSinkInterface<VideoFrame>* const incoming_video_stream_; |
mflodman | cfc8e3b | 2016-05-03 21:22:04 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | } // namespace webrtc |
| 101 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 102 | #endif // VIDEO_VIDEO_STREAM_DECODER_H_ |