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

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

Issue 2487633002: Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (Closed)
Patch Set: Rebase, and update rtcstatscollector_unittest.cc. Created 4 years, 1 month 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/media/engine/webrtcvideoengine2.h ('k') | webrtc/pc/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
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; 517 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << ".";
518 if (!channel->AddRecvStream(sp, true)) { 518 if (!channel->AddRecvStream(sp, true)) {
519 LOG(LS_WARNING) << "Could not create default receive stream."; 519 LOG(LS_WARNING) << "Could not create default receive stream.";
520 } 520 }
521 521
522 channel->SetSink(ssrc, default_sink_); 522 channel->SetSink(ssrc, default_sink_);
523 default_recv_ssrc_ = ssrc; 523 default_recv_ssrc_ = ssrc;
524 return kDeliverPacket; 524 return kDeliverPacket;
525 } 525 }
526 526
527 rtc::VideoSinkInterface<VideoFrame>* 527 rtc::VideoSinkInterface<webrtc::VideoFrame>*
528 DefaultUnsignalledSsrcHandler::GetDefaultSink() const { 528 DefaultUnsignalledSsrcHandler::GetDefaultSink() const {
529 return default_sink_; 529 return default_sink_;
530 } 530 }
531 531
532 void DefaultUnsignalledSsrcHandler::SetDefaultSink( 532 void DefaultUnsignalledSsrcHandler::SetDefaultSink(
533 VideoMediaChannel* channel, 533 VideoMediaChannel* channel,
534 rtc::VideoSinkInterface<VideoFrame>* sink) { 534 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
535 default_sink_ = sink; 535 default_sink_ = sink;
536 if (default_recv_ssrc_ != 0) { 536 if (default_recv_ssrc_ != 0) {
537 channel->SetSink(default_recv_ssrc_, default_sink_); 537 channel->SetSink(default_recv_ssrc_, default_sink_);
538 } 538 }
539 } 539 }
540 540
541 WebRtcVideoEngine2::WebRtcVideoEngine2() 541 WebRtcVideoEngine2::WebRtcVideoEngine2()
542 : initialized_(false), 542 : initialized_(false),
543 external_decoder_factory_(NULL), 543 external_decoder_factory_(NULL),
544 external_encoder_factory_(NULL) { 544 external_encoder_factory_(NULL) {
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 return true; 1059 return true;
1060 } 1060 }
1061 1061
1062 // TODO(nisse): The enable argument was used for mute logic which has 1062 // TODO(nisse): The enable argument was used for mute logic which has
1063 // been moved to VideoBroadcaster. So remove the argument from this 1063 // been moved to VideoBroadcaster. So remove the argument from this
1064 // method. 1064 // method.
1065 bool WebRtcVideoChannel2::SetVideoSend( 1065 bool WebRtcVideoChannel2::SetVideoSend(
1066 uint32_t ssrc, 1066 uint32_t ssrc,
1067 bool enable, 1067 bool enable,
1068 const VideoOptions* options, 1068 const VideoOptions* options,
1069 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { 1069 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
1070 TRACE_EVENT0("webrtc", "SetVideoSend"); 1070 TRACE_EVENT0("webrtc", "SetVideoSend");
1071 RTC_DCHECK(ssrc != 0); 1071 RTC_DCHECK(ssrc != 0);
1072 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable 1072 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable
1073 << ", options: " << (options ? options->ToString() : "nullptr") 1073 << ", options: " << (options ? options->ToString() : "nullptr")
1074 << ", source = " << (source ? "(source)" : "nullptr") << ")"; 1074 << ", source = " << (source ? "(source)" : "nullptr") << ")";
1075 1075
1076 rtc::CritScope stream_lock(&stream_crit_); 1076 rtc::CritScope stream_lock(&stream_crit_);
1077 const auto& kv = send_streams_.find(ssrc); 1077 const auto& kv = send_streams_.find(ssrc);
1078 if (kv == send_streams_.end()) { 1078 if (kv == send_streams_.end()) {
1079 // Allow unknown ssrc only if source is null. 1079 // Allow unknown ssrc only if source is null.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 if (stream == receive_streams_.end()) { 1300 if (stream == receive_streams_.end()) {
1301 LOG(LS_ERROR) << "Stream not found for ssrc: " << ssrc; 1301 LOG(LS_ERROR) << "Stream not found for ssrc: " << ssrc;
1302 return false; 1302 return false;
1303 } 1303 }
1304 DeleteReceiveStream(stream->second); 1304 DeleteReceiveStream(stream->second);
1305 receive_streams_.erase(stream); 1305 receive_streams_.erase(stream);
1306 1306
1307 return true; 1307 return true;
1308 } 1308 }
1309 1309
1310 bool WebRtcVideoChannel2::SetSink(uint32_t ssrc, 1310 bool WebRtcVideoChannel2::SetSink(
1311 rtc::VideoSinkInterface<VideoFrame>* sink) { 1311 uint32_t ssrc,
1312 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
1312 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " 1313 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " "
1313 << (sink ? "(ptr)" : "nullptr"); 1314 << (sink ? "(ptr)" : "nullptr");
1314 if (ssrc == 0) { 1315 if (ssrc == 0) {
1315 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); 1316 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink);
1316 return true; 1317 return true;
1317 } 1318 }
1318 1319
1319 rtc::CritScope stream_lock(&stream_crit_); 1320 rtc::CritScope stream_lock(&stream_crit_);
1320 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = 1321 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it =
1321 receive_streams_.find(ssrc); 1322 receive_streams_.find(ssrc);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 } 1592 }
1592 1593
1593 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { 1594 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
1594 if (stream_ != NULL) { 1595 if (stream_ != NULL) {
1595 call_->DestroyVideoSendStream(stream_); 1596 call_->DestroyVideoSendStream(stream_);
1596 } 1597 }
1597 DestroyVideoEncoder(&allocated_encoder_); 1598 DestroyVideoEncoder(&allocated_encoder_);
1598 } 1599 }
1599 1600
1600 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( 1601 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame(
1601 const VideoFrame& frame) { 1602 const webrtc::VideoFrame& frame) {
1602 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); 1603 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame");
1603 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 1604 webrtc::VideoFrame video_frame(frame.video_frame_buffer(),
1604 frame.rotation(), 1605 frame.rotation(),
1605 frame.timestamp_us()); 1606 frame.timestamp_us());
1606 1607
1607 rtc::CritScope cs(&lock_); 1608 rtc::CritScope cs(&lock_);
1608 1609
1609 if (video_frame.width() != last_frame_info_.width || 1610 if (video_frame.width() != last_frame_info_.width ||
1610 video_frame.height() != last_frame_info_.height || 1611 video_frame.height() != last_frame_info_.height ||
1611 video_frame.rotation() != last_frame_info_.rotation || 1612 video_frame.rotation() != last_frame_info_.rotation ||
(...skipping 18 matching lines...) Expand all
1630 1631
1631 // Forward frame to the encoder regardless if we are sending or not. This is 1632 // Forward frame to the encoder regardless if we are sending or not. This is
1632 // to ensure that the encoder can be reconfigured with the correct frame size 1633 // to ensure that the encoder can be reconfigured with the correct frame size
1633 // as quickly as possible. 1634 // as quickly as possible.
1634 encoder_sink_->OnFrame(video_frame); 1635 encoder_sink_->OnFrame(video_frame);
1635 } 1636 }
1636 1637
1637 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( 1638 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend(
1638 bool enable, 1639 bool enable,
1639 const VideoOptions* options, 1640 const VideoOptions* options,
1640 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { 1641 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
1641 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); 1642 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend");
1642 RTC_DCHECK_RUN_ON(&thread_checker_); 1643 RTC_DCHECK_RUN_ON(&thread_checker_);
1643 1644
1644 // Ignore |options| pointer if |enable| is false. 1645 // Ignore |options| pointer if |enable| is false.
1645 bool options_present = enable && options; 1646 bool options_present = enable && options;
1646 bool source_changing = source_ != source; 1647 bool source_changing = source_ != source;
1647 1648
1648 if (options_present) { 1649 if (options_present) {
1649 VideoOptions old_options = parameters_.options; 1650 VideoOptions old_options = parameters_.options;
1650 parameters_.options.SetAll(*options); 1651 parameters_.options.SetAll(*options);
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 } 2387 }
2387 2388
2388 sink_->OnFrame(frame); 2389 sink_->OnFrame(frame);
2389 } 2390 }
2390 2391
2391 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { 2392 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const {
2392 return default_stream_; 2393 return default_stream_;
2393 } 2394 }
2394 2395
2395 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( 2396 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink(
2396 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { 2397 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) {
2397 rtc::CritScope crit(&sink_lock_); 2398 rtc::CritScope crit(&sink_lock_);
2398 sink_ = sink; 2399 sink_ = sink;
2399 } 2400 }
2400 2401
2401 std::string 2402 std::string
2402 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( 2403 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType(
2403 int payload_type) { 2404 int payload_type) {
2404 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { 2405 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) {
2405 if (decoder.payload_type == payload_type) { 2406 if (decoder.payload_type == payload_type) {
2406 return decoder.payload_name; 2407 return decoder.payload_name;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 rtx_mapping[video_codecs[i].codec.id] != 2575 rtx_mapping[video_codecs[i].codec.id] !=
2575 ulpfec_config.red_payload_type) { 2576 ulpfec_config.red_payload_type) {
2576 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2577 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2577 } 2578 }
2578 } 2579 }
2579 2580
2580 return video_codecs; 2581 return video_codecs;
2581 } 2582 }
2582 2583
2583 } // namespace cricket 2584 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/pc/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698