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

Side by Side Diff: talk/media/webrtc/webrtcvideoengine2.cc

Issue 1594973006: New rtc::VideoSinkInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Use rtc::VideoSinkInterface on the call chain VideoSource --> CaptureRenderAdapter Created 4 years, 11 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 return true; 1173 return true;
1174 } 1174 }
1175 1175
1176 rtc::CritScope stream_lock(&stream_crit_); 1176 rtc::CritScope stream_lock(&stream_crit_);
1177 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = 1177 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it =
1178 receive_streams_.find(ssrc); 1178 receive_streams_.find(ssrc);
1179 if (it == receive_streams_.end()) { 1179 if (it == receive_streams_.end()) {
1180 return false; 1180 return false;
1181 } 1181 }
1182 1182
1183 it->second->SetRenderer(renderer); 1183 it->second->SetSink(renderer);
1184 return true; 1184 return true;
1185 } 1185 }
1186 1186
1187 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { 1187 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) {
1188 info->Clear(); 1188 info->Clear();
1189 FillSenderStats(info); 1189 FillSenderStats(info);
1190 FillReceiverStats(info); 1190 FillReceiverStats(info);
1191 webrtc::Call::Stats stats = call_->GetStats(); 1191 webrtc::Call::Stats stats = call_->GetStats();
1192 FillBandwidthEstimationStats(stats, info); 1192 FillBandwidthEstimationStats(stats, info);
1193 if (stats.rtt_ms != -1) { 1193 if (stats.rtt_ms != -1) {
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 const std::vector<VideoCodecSettings>& recv_codecs, 2219 const std::vector<VideoCodecSettings>& recv_codecs,
2220 bool disable_prerenderer_smoothing) 2220 bool disable_prerenderer_smoothing)
2221 : call_(call), 2221 : call_(call),
2222 ssrcs_(sp.ssrcs), 2222 ssrcs_(sp.ssrcs),
2223 ssrc_groups_(sp.ssrc_groups), 2223 ssrc_groups_(sp.ssrc_groups),
2224 stream_(NULL), 2224 stream_(NULL),
2225 default_stream_(default_stream), 2225 default_stream_(default_stream),
2226 config_(config), 2226 config_(config),
2227 external_decoder_factory_(external_decoder_factory), 2227 external_decoder_factory_(external_decoder_factory),
2228 disable_prerenderer_smoothing_(disable_prerenderer_smoothing), 2228 disable_prerenderer_smoothing_(disable_prerenderer_smoothing),
2229 renderer_(NULL), 2229 sink_(NULL),
2230 last_width_(-1), 2230 last_width_(-1),
2231 last_height_(-1), 2231 last_height_(-1),
2232 first_frame_timestamp_(-1), 2232 first_frame_timestamp_(-1),
2233 estimated_remote_start_ntp_time_ms_(0) { 2233 estimated_remote_start_ntp_time_ms_(0) {
2234 config_.renderer = this; 2234 config_.renderer = this;
2235 // SetRecvCodecs will also reset (start) the VideoReceiveStream. 2235 // SetRecvCodecs will also reset (start) the VideoReceiveStream.
2236 LOG(LS_INFO) << "SetRecvCodecs (recv) because we are creating the receive " 2236 LOG(LS_INFO) << "SetRecvCodecs (recv) because we are creating the receive "
2237 "stream for the first time: " 2237 "stream for the first time: "
2238 << CodecSettingsVectorToString(recv_codecs); 2238 << CodecSettingsVectorToString(recv_codecs);
2239 SetRecvCodecs(recv_codecs); 2239 SetRecvCodecs(recv_codecs);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 (*allocated_decoders)[i].external_decoder); 2412 (*allocated_decoders)[i].external_decoder);
2413 } 2413 }
2414 delete (*allocated_decoders)[i].decoder; 2414 delete (*allocated_decoders)[i].decoder;
2415 } 2415 }
2416 allocated_decoders->clear(); 2416 allocated_decoders->clear();
2417 } 2417 }
2418 2418
2419 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RenderFrame( 2419 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RenderFrame(
2420 const webrtc::VideoFrame& frame, 2420 const webrtc::VideoFrame& frame,
2421 int time_to_render_ms) { 2421 int time_to_render_ms) {
2422 rtc::CritScope crit(&renderer_lock_); 2422 rtc::CritScope crit(&sink_lock_);
2423 2423
2424 if (first_frame_timestamp_ < 0) 2424 if (first_frame_timestamp_ < 0)
2425 first_frame_timestamp_ = frame.timestamp(); 2425 first_frame_timestamp_ = frame.timestamp();
2426 int64_t rtp_time_elapsed_since_first_frame = 2426 int64_t rtp_time_elapsed_since_first_frame =
2427 (timestamp_wraparound_handler_.Unwrap(frame.timestamp()) - 2427 (timestamp_wraparound_handler_.Unwrap(frame.timestamp()) -
2428 first_frame_timestamp_); 2428 first_frame_timestamp_);
2429 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / 2429 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame /
2430 (cricket::kVideoCodecClockrate / 1000); 2430 (cricket::kVideoCodecClockrate / 1000);
2431 if (frame.ntp_time_ms() > 0) 2431 if (frame.ntp_time_ms() > 0)
2432 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; 2432 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms;
2433 2433
2434 if (renderer_ == NULL) { 2434 if (sink_ == NULL) {
2435 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoRenderer."; 2435 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink.";
2436 return; 2436 return;
2437 } 2437 }
2438 2438
2439 last_width_ = frame.width(); 2439 last_width_ = frame.width();
2440 last_height_ = frame.height(); 2440 last_height_ = frame.height();
2441 2441
2442 const WebRtcVideoFrame render_frame( 2442 const WebRtcVideoFrame render_frame(
2443 frame.video_frame_buffer(), 2443 frame.video_frame_buffer(),
2444 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation()); 2444 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation());
2445 renderer_->RenderFrame(&render_frame); 2445 sink_->OnFrame(render_frame);
2446 } 2446 }
2447 2447
2448 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsTextureSupported() const { 2448 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsTextureSupported() const {
2449 return true; 2449 return true;
2450 } 2450 }
2451 2451
2452 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::SmoothsRenderedFrames() 2452 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::SmoothsRenderedFrames()
2453 const { 2453 const {
2454 return disable_prerenderer_smoothing_; 2454 return disable_prerenderer_smoothing_;
2455 } 2455 }
2456 2456
2457 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { 2457 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const {
2458 return default_stream_; 2458 return default_stream_;
2459 } 2459 }
2460 2460
2461 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetRenderer( 2461 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink(
2462 cricket::VideoRenderer* renderer) { 2462 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
2463 rtc::CritScope crit(&renderer_lock_); 2463 rtc::CritScope crit(&sink_lock_);
2464 renderer_ = renderer; 2464 sink_ = sink;
2465 } 2465 }
2466 2466
2467 std::string 2467 std::string
2468 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( 2468 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType(
2469 int payload_type) { 2469 int payload_type) {
2470 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { 2470 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) {
2471 if (decoder.payload_type == payload_type) { 2471 if (decoder.payload_type == payload_type) {
2472 return decoder.payload_name; 2472 return decoder.payload_name;
2473 } 2473 }
2474 } 2474 }
(...skipping 13 matching lines...) Expand all
2488 info.packets_rcvd = stats.rtp_stats.transmitted.packets; 2488 info.packets_rcvd = stats.rtp_stats.transmitted.packets;
2489 info.packets_lost = stats.rtcp_stats.cumulative_lost; 2489 info.packets_lost = stats.rtcp_stats.cumulative_lost;
2490 info.fraction_lost = 2490 info.fraction_lost =
2491 static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8); 2491 static_cast<float>(stats.rtcp_stats.fraction_lost) / (1 << 8);
2492 2492
2493 info.framerate_rcvd = stats.network_frame_rate; 2493 info.framerate_rcvd = stats.network_frame_rate;
2494 info.framerate_decoded = stats.decode_frame_rate; 2494 info.framerate_decoded = stats.decode_frame_rate;
2495 info.framerate_output = stats.render_frame_rate; 2495 info.framerate_output = stats.render_frame_rate;
2496 2496
2497 { 2497 {
2498 rtc::CritScope frame_cs(&renderer_lock_); 2498 rtc::CritScope frame_cs(&sink_lock_);
2499 info.frame_width = last_width_; 2499 info.frame_width = last_width_;
2500 info.frame_height = last_height_; 2500 info.frame_height = last_height_;
2501 info.capture_start_ntp_time_ms = estimated_remote_start_ntp_time_ms_; 2501 info.capture_start_ntp_time_ms = estimated_remote_start_ntp_time_ms_;
2502 } 2502 }
2503 2503
2504 info.decode_ms = stats.decode_ms; 2504 info.decode_ms = stats.decode_ms;
2505 info.max_decode_ms = stats.max_decode_ms; 2505 info.max_decode_ms = stats.max_decode_ms;
2506 info.current_delay_ms = stats.current_delay_ms; 2506 info.current_delay_ms = stats.current_delay_ms;
2507 info.target_delay_ms = stats.target_delay_ms; 2507 info.target_delay_ms = stats.target_delay_ms;
2508 info.jitter_buffer_ms = stats.jitter_buffer_ms; 2508 info.jitter_buffer_ms = stats.jitter_buffer_ms;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2626 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2627 } 2627 }
2628 } 2628 }
2629 2629
2630 return video_codecs; 2630 return video_codecs;
2631 } 2631 }
2632 2632
2633 } // namespace cricket 2633 } // namespace cricket
2634 2634
2635 #endif // HAVE_WEBRTC_VIDEO 2635 #endif // HAVE_WEBRTC_VIDEO
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698