Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: webrtc/video/video_stream_decoder.cc

Issue 1929313002: Removed all RTP dependencies from ViEChannel and renamed class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_stream_decoder.h ('k') | webrtc/video/vie_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
11 #include "webrtc/video/video_stream_decoder.h"
12
13 #include <algorithm>
14 #include <map>
15 #include <vector>
16
17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h"
19 #include "webrtc/common_video/include/frame_callback.h"
20 #include "webrtc/common_video/include/incoming_video_stream.h"
21 #include "webrtc/modules/video_coding/video_coding_impl.h"
22 #include "webrtc/modules/video_processing/include/video_processing.h"
23 #include "webrtc/system_wrappers/include/metrics.h"
24 #include "webrtc/video/call_stats.h"
25 #include "webrtc/video/payload_router.h"
26 #include "webrtc/video/receive_statistics_proxy.h"
27
28 namespace webrtc {
29
30 VideoStreamDecoder::VideoStreamDecoder(
31 vcm::VideoReceiver* video_receiver,
32 VCMFrameTypeCallback* vcm_frame_type_callback,
33 VCMPacketRequestCallback* vcm_packet_request_callback,
34 bool enable_nack,
35 ReceiveStatisticsProxy* receive_statistics_proxy,
36 IncomingVideoStream* incoming_video_stream,
37 I420FrameCallback* pre_render_callback)
38 : video_receiver_(video_receiver),
39 receive_stats_callback_(receive_statistics_proxy),
40 incoming_video_stream_(incoming_video_stream),
41 pre_render_callback_(pre_render_callback),
42 last_rtt_ms_(0) {
43 RTC_DCHECK(video_receiver_);
44
45 static const int kMaxPacketAgeToNack = 450;
46 static const int kMaxNackListSize = 250;
47 video_receiver_->SetNackSettings(kMaxNackListSize,
48 kMaxPacketAgeToNack, 0);
49 video_receiver_->RegisterReceiveCallback(this);
50 video_receiver_->RegisterFrameTypeCallback(vcm_frame_type_callback);
51 video_receiver_->RegisterReceiveStatisticsCallback(this);
52 video_receiver_->RegisterDecoderTimingCallback(this);
53 static const int kDefaultRenderDelayMs = 10;
54 video_receiver_->SetRenderDelay(kDefaultRenderDelayMs);
55
56 VCMVideoProtection video_protection = enable_nack ? kProtectionNack
57 : kProtectionNone;
58 VCMDecodeErrorMode decode_error_mode = enable_nack ? kNoErrors : kWithErrors;
59 video_receiver_->SetVideoProtection(video_protection, true);
60 video_receiver_->SetDecodeErrorMode(decode_error_mode);
61 VCMPacketRequestCallback* packet_request_callback =
62 enable_nack ? vcm_packet_request_callback : nullptr;
63 video_receiver_->RegisterPacketRequestCallback(packet_request_callback);
64 }
65
66 VideoStreamDecoder::~VideoStreamDecoder() {}
67
68 // Do not acquire the lock of |video_receiver_| in this function. Decode
69 // callback won't necessarily be called from the decoding thread. The decoding
70 // thread may have held the lock when calling VideoDecoder::Decode, Reset, or
71 // Release. Acquiring the same lock in the path of decode callback can deadlock.
72 int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame) { // NOLINT
73 if (pre_render_callback_)
74 pre_render_callback_->FrameCallback(&video_frame);
75
76 incoming_video_stream_->OnFrame(video_frame);
77 return 0;
78 }
79
80 int32_t VideoStreamDecoder::ReceivedDecodedReferenceFrame(
81 const uint64_t picture_id) {
82 RTC_NOTREACHED();
83 return 0;
84 }
85
86 void VideoStreamDecoder::OnIncomingPayloadType(int payload_type) {
87 receive_stats_callback_->OnIncomingPayloadType(payload_type);
88 }
89
90 void VideoStreamDecoder::OnDecoderImplementationName(
91 const char* implementation_name) {
92 receive_stats_callback_->OnDecoderImplementationName(implementation_name);
93 }
94
95 void VideoStreamDecoder::OnReceiveRatesUpdated(uint32_t bit_rate,
96 uint32_t frame_rate) {
97 receive_stats_callback_->OnIncomingRate(frame_rate, bit_rate);
98 }
99
100 void VideoStreamDecoder::OnDiscardedPacketsUpdated(int discarded_packets) {
101 receive_stats_callback_->OnDiscardedPacketsUpdated(discarded_packets);
102 }
103
104 void VideoStreamDecoder::OnFrameCountsUpdated(const FrameCounts& frame_counts) {
105 receive_stats_callback_->OnFrameCountsUpdated(frame_counts);
106 }
107
108 void VideoStreamDecoder::OnDecoderTiming(int decode_ms,
109 int max_decode_ms,
110 int current_delay_ms,
111 int target_delay_ms,
112 int jitter_buffer_ms,
113 int min_playout_delay_ms,
114 int render_delay_ms) {
115 int last_rtt = -1;
116 {
117 rtc::CritScope lock(&crit_);
118 last_rtt = last_rtt_ms_;
119 }
120
121 receive_stats_callback_->OnDecoderTiming(
122 decode_ms, max_decode_ms, current_delay_ms, target_delay_ms,
123 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms, last_rtt);
124 }
125
126 void VideoStreamDecoder::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
127 video_receiver_->SetReceiveChannelParameters(max_rtt_ms);
128
129 rtc::CritScope lock(&crit_);
130 last_rtt_ms_ = avg_rtt_ms;
131 }
132 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_stream_decoder.h ('k') | webrtc/video/vie_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698