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

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

Issue 2071473002: Reland of Split IncomingVideoStream into two implementations, with smoothing and without. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: add explicit Created 4 years, 6 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/video/video_stream_decoder.h" 11 #include "webrtc/video/video_stream_decoder.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <map> 14 #include <map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/common_video/include/frame_callback.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" 20 #include "webrtc/modules/video_coding/video_coding_impl.h"
22 #include "webrtc/modules/video_processing/include/video_processing.h" 21 #include "webrtc/modules/video_processing/include/video_processing.h"
23 #include "webrtc/system_wrappers/include/metrics.h" 22 #include "webrtc/system_wrappers/include/metrics.h"
24 #include "webrtc/video/call_stats.h" 23 #include "webrtc/video/call_stats.h"
25 #include "webrtc/video/payload_router.h" 24 #include "webrtc/video/payload_router.h"
26 #include "webrtc/video/receive_statistics_proxy.h" 25 #include "webrtc/video/receive_statistics_proxy.h"
27 26
28 namespace webrtc { 27 namespace webrtc {
29 28
30 VideoStreamDecoder::VideoStreamDecoder( 29 VideoStreamDecoder::VideoStreamDecoder(
31 vcm::VideoReceiver* video_receiver, 30 vcm::VideoReceiver* video_receiver,
32 VCMFrameTypeCallback* vcm_frame_type_callback, 31 VCMFrameTypeCallback* vcm_frame_type_callback,
33 VCMPacketRequestCallback* vcm_packet_request_callback, 32 VCMPacketRequestCallback* vcm_packet_request_callback,
34 bool enable_nack, 33 bool enable_nack,
35 bool enable_fec, // TODO(philipel): Actually use this. 34 bool enable_fec,
36 ReceiveStatisticsProxy* receive_statistics_proxy, 35 ReceiveStatisticsProxy* receive_statistics_proxy,
37 IncomingVideoStream* incoming_video_stream, 36 rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream,
38 I420FrameCallback* pre_render_callback) 37 I420FrameCallback* pre_render_callback)
39 : video_receiver_(video_receiver), 38 : video_receiver_(video_receiver),
40 receive_stats_callback_(receive_statistics_proxy), 39 receive_stats_callback_(receive_statistics_proxy),
41 incoming_video_stream_(incoming_video_stream), 40 incoming_video_stream_(incoming_video_stream),
42 pre_render_callback_(pre_render_callback), 41 pre_render_callback_(pre_render_callback),
43 last_rtt_ms_(0) { 42 last_rtt_ms_(0) {
44 RTC_DCHECK(video_receiver_); 43 RTC_DCHECK(video_receiver_);
45 44
46 static const int kMaxPacketAgeToNack = 450; 45 static const int kMaxPacketAgeToNack = 450;
47 static const int kMaxNackListSize = 250; 46 static const int kMaxNackListSize = 250;
48 video_receiver_->SetNackSettings(kMaxNackListSize, 47 video_receiver_->SetNackSettings(kMaxNackListSize,
49 kMaxPacketAgeToNack, 0); 48 kMaxPacketAgeToNack, 0);
50 video_receiver_->RegisterReceiveCallback(this); 49 video_receiver_->RegisterReceiveCallback(this);
51 video_receiver_->RegisterFrameTypeCallback(vcm_frame_type_callback); 50 video_receiver_->RegisterFrameTypeCallback(vcm_frame_type_callback);
52 video_receiver_->RegisterReceiveStatisticsCallback(this); 51 video_receiver_->RegisterReceiveStatisticsCallback(this);
53 video_receiver_->RegisterDecoderTimingCallback(this); 52 video_receiver_->RegisterDecoderTimingCallback(this);
54 static const int kDefaultRenderDelayMs = 10;
55 video_receiver_->SetRenderDelay(kDefaultRenderDelayMs);
56 53
57 VCMVideoProtection video_protection = kProtectionNone; 54 VCMVideoProtection video_protection =
58 if (enable_nack) { 55 enable_nack ? (enable_fec ? kProtectionNackFEC : kProtectionNack)
59 if (enable_fec) 56 : kProtectionNone;
60 video_protection = kProtectionNackFEC;
61 else
62 video_protection = kProtectionNack;
63 }
64 57
65 VCMDecodeErrorMode decode_error_mode = enable_nack ? kNoErrors : kWithErrors; 58 VCMDecodeErrorMode decode_error_mode = enable_nack ? kNoErrors : kWithErrors;
66 video_receiver_->SetVideoProtection(video_protection, true); 59 video_receiver_->SetVideoProtection(video_protection, true);
67 video_receiver_->SetDecodeErrorMode(decode_error_mode); 60 video_receiver_->SetDecodeErrorMode(decode_error_mode);
68 VCMPacketRequestCallback* packet_request_callback = 61 VCMPacketRequestCallback* packet_request_callback =
69 enable_nack ? vcm_packet_request_callback : nullptr; 62 enable_nack ? vcm_packet_request_callback : nullptr;
70 video_receiver_->RegisterPacketRequestCallback(packet_request_callback); 63 video_receiver_->RegisterPacketRequestCallback(packet_request_callback);
71 } 64 }
72 65
73 VideoStreamDecoder::~VideoStreamDecoder() {} 66 VideoStreamDecoder::~VideoStreamDecoder() {
67 // Unset all the callback pointers that we set in the ctor.
68 video_receiver_->RegisterPacketRequestCallback(nullptr);
69 video_receiver_->RegisterDecoderTimingCallback(nullptr);
70 video_receiver_->RegisterReceiveStatisticsCallback(nullptr);
71 video_receiver_->RegisterFrameTypeCallback(nullptr);
72 video_receiver_->RegisterReceiveCallback(nullptr);
73 }
74 74
75 // Do not acquire the lock of |video_receiver_| in this function. Decode 75 // Do not acquire the lock of |video_receiver_| in this function. Decode
76 // callback won't necessarily be called from the decoding thread. The decoding 76 // callback won't necessarily be called from the decoding thread. The decoding
77 // thread may have held the lock when calling VideoDecoder::Decode, Reset, or 77 // thread may have held the lock when calling VideoDecoder::Decode, Reset, or
78 // Release. Acquiring the same lock in the path of decode callback can deadlock. 78 // Release. Acquiring the same lock in the path of decode callback can deadlock.
79 int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame) { // NOLINT 79 int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame) { // NOLINT
80 if (pre_render_callback_) { 80 if (pre_render_callback_) {
81 // Post processing is not supported if the frame is backed by a texture. 81 // Post processing is not supported if the frame is backed by a texture.
82 if (!video_frame.video_frame_buffer()->native_handle()) { 82 if (!video_frame.video_frame_buffer()->native_handle()) {
83 pre_render_callback_->FrameCallback(&video_frame); 83 pre_render_callback_->FrameCallback(&video_frame);
84 } 84 }
85 } 85 }
86 86
87 incoming_video_stream_->OnFrame(video_frame); 87 if (incoming_video_stream_)
88 incoming_video_stream_->OnFrame(video_frame);
89
88 return 0; 90 return 0;
89 } 91 }
90 92
91 int32_t VideoStreamDecoder::ReceivedDecodedReferenceFrame( 93 int32_t VideoStreamDecoder::ReceivedDecodedReferenceFrame(
92 const uint64_t picture_id) { 94 const uint64_t picture_id) {
93 RTC_NOTREACHED(); 95 RTC_NOTREACHED();
94 return 0; 96 return 0;
95 } 97 }
96 98
97 void VideoStreamDecoder::OnIncomingPayloadType(int payload_type) { 99 void VideoStreamDecoder::OnIncomingPayloadType(int payload_type) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms, last_rtt); 136 jitter_buffer_ms, min_playout_delay_ms, render_delay_ms, last_rtt);
135 } 137 }
136 138
137 void VideoStreamDecoder::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 139 void VideoStreamDecoder::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
138 video_receiver_->SetReceiveChannelParameters(max_rtt_ms); 140 video_receiver_->SetReceiveChannelParameters(max_rtt_ms);
139 141
140 rtc::CritScope lock(&crit_); 142 rtc::CritScope lock(&crit_);
141 last_rtt_ms_ = avg_rtt_ms; 143 last_rtt_ms_ = avg_rtt_ms;
142 } 144 }
143 } // namespace webrtc 145 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_stream_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698