OLD | NEW |
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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; | 513 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; |
514 if (!channel->AddRecvStream(sp, true)) { | 514 if (!channel->AddRecvStream(sp, true)) { |
515 LOG(LS_WARNING) << "Could not create default receive stream."; | 515 LOG(LS_WARNING) << "Could not create default receive stream."; |
516 } | 516 } |
517 | 517 |
518 channel->SetSink(ssrc, default_sink_); | 518 channel->SetSink(ssrc, default_sink_); |
519 default_recv_ssrc_ = ssrc; | 519 default_recv_ssrc_ = ssrc; |
520 return kDeliverPacket; | 520 return kDeliverPacket; |
521 } | 521 } |
522 | 522 |
523 rtc::VideoSinkInterface<webrtc::VideoFrame>* | 523 rtc::VideoSinkInterface<VideoFrame>* |
524 DefaultUnsignalledSsrcHandler::GetDefaultSink() const { | 524 DefaultUnsignalledSsrcHandler::GetDefaultSink() const { |
525 return default_sink_; | 525 return default_sink_; |
526 } | 526 } |
527 | 527 |
528 void DefaultUnsignalledSsrcHandler::SetDefaultSink( | 528 void DefaultUnsignalledSsrcHandler::SetDefaultSink( |
529 VideoMediaChannel* channel, | 529 VideoMediaChannel* channel, |
530 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 530 rtc::VideoSinkInterface<VideoFrame>* sink) { |
531 default_sink_ = sink; | 531 default_sink_ = sink; |
532 if (default_recv_ssrc_ != 0) { | 532 if (default_recv_ssrc_ != 0) { |
533 channel->SetSink(default_recv_ssrc_, default_sink_); | 533 channel->SetSink(default_recv_ssrc_, default_sink_); |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
537 WebRtcVideoEngine2::WebRtcVideoEngine2() | 537 WebRtcVideoEngine2::WebRtcVideoEngine2() |
538 : initialized_(false), | 538 : initialized_(false), |
539 external_decoder_factory_(NULL), | 539 external_decoder_factory_(NULL), |
540 external_encoder_factory_(NULL) { | 540 external_encoder_factory_(NULL) { |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 return true; | 1055 return true; |
1056 } | 1056 } |
1057 | 1057 |
1058 // TODO(nisse): The enable argument was used for mute logic which has | 1058 // TODO(nisse): The enable argument was used for mute logic which has |
1059 // been moved to VideoBroadcaster. So remove the argument from this | 1059 // been moved to VideoBroadcaster. So remove the argument from this |
1060 // method. | 1060 // method. |
1061 bool WebRtcVideoChannel2::SetVideoSend( | 1061 bool WebRtcVideoChannel2::SetVideoSend( |
1062 uint32_t ssrc, | 1062 uint32_t ssrc, |
1063 bool enable, | 1063 bool enable, |
1064 const VideoOptions* options, | 1064 const VideoOptions* options, |
1065 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { | 1065 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
1066 TRACE_EVENT0("webrtc", "SetVideoSend"); | 1066 TRACE_EVENT0("webrtc", "SetVideoSend"); |
1067 RTC_DCHECK(ssrc != 0); | 1067 RTC_DCHECK(ssrc != 0); |
1068 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable | 1068 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable |
1069 << ", options: " << (options ? options->ToString() : "nullptr") | 1069 << ", options: " << (options ? options->ToString() : "nullptr") |
1070 << ", source = " << (source ? "(source)" : "nullptr") << ")"; | 1070 << ", source = " << (source ? "(source)" : "nullptr") << ")"; |
1071 | 1071 |
1072 rtc::CritScope stream_lock(&stream_crit_); | 1072 rtc::CritScope stream_lock(&stream_crit_); |
1073 const auto& kv = send_streams_.find(ssrc); | 1073 const auto& kv = send_streams_.find(ssrc); |
1074 if (kv == send_streams_.end()) { | 1074 if (kv == send_streams_.end()) { |
1075 // Allow unknown ssrc only if source is null. | 1075 // Allow unknown ssrc only if source is null. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 if (stream == receive_streams_.end()) { | 1296 if (stream == receive_streams_.end()) { |
1297 LOG(LS_ERROR) << "Stream not found for ssrc: " << ssrc; | 1297 LOG(LS_ERROR) << "Stream not found for ssrc: " << ssrc; |
1298 return false; | 1298 return false; |
1299 } | 1299 } |
1300 DeleteReceiveStream(stream->second); | 1300 DeleteReceiveStream(stream->second); |
1301 receive_streams_.erase(stream); | 1301 receive_streams_.erase(stream); |
1302 | 1302 |
1303 return true; | 1303 return true; |
1304 } | 1304 } |
1305 | 1305 |
1306 bool WebRtcVideoChannel2::SetSink( | 1306 bool WebRtcVideoChannel2::SetSink(uint32_t ssrc, |
1307 uint32_t ssrc, | 1307 rtc::VideoSinkInterface<VideoFrame>* sink) { |
1308 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | |
1309 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " | 1308 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " |
1310 << (sink ? "(ptr)" : "nullptr"); | 1309 << (sink ? "(ptr)" : "nullptr"); |
1311 if (ssrc == 0) { | 1310 if (ssrc == 0) { |
1312 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); | 1311 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); |
1313 return true; | 1312 return true; |
1314 } | 1313 } |
1315 | 1314 |
1316 rtc::CritScope stream_lock(&stream_crit_); | 1315 rtc::CritScope stream_lock(&stream_crit_); |
1317 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | 1316 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = |
1318 receive_streams_.find(ssrc); | 1317 receive_streams_.find(ssrc); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 } | 1581 } |
1583 | 1582 |
1584 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { | 1583 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { |
1585 if (stream_ != NULL) { | 1584 if (stream_ != NULL) { |
1586 call_->DestroyVideoSendStream(stream_); | 1585 call_->DestroyVideoSendStream(stream_); |
1587 } | 1586 } |
1588 DestroyVideoEncoder(&allocated_encoder_); | 1587 DestroyVideoEncoder(&allocated_encoder_); |
1589 } | 1588 } |
1590 | 1589 |
1591 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( | 1590 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( |
1592 const webrtc::VideoFrame& frame) { | 1591 const VideoFrame& frame) { |
1593 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); | 1592 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); |
1594 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), | 1593 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), |
1595 frame.rotation(), | 1594 frame.rotation(), |
1596 frame.timestamp_us()); | 1595 frame.timestamp_us()); |
1597 | 1596 |
1598 rtc::CritScope cs(&lock_); | 1597 rtc::CritScope cs(&lock_); |
1599 | 1598 |
1600 if (video_frame.width() != last_frame_info_.width || | 1599 if (video_frame.width() != last_frame_info_.width || |
1601 video_frame.height() != last_frame_info_.height || | 1600 video_frame.height() != last_frame_info_.height || |
1602 video_frame.rotation() != last_frame_info_.rotation || | 1601 video_frame.rotation() != last_frame_info_.rotation || |
(...skipping 18 matching lines...) Expand all Loading... |
1621 | 1620 |
1622 // Forward frame to the encoder regardless if we are sending or not. This is | 1621 // Forward frame to the encoder regardless if we are sending or not. This is |
1623 // to ensure that the encoder can be reconfigured with the correct frame size | 1622 // to ensure that the encoder can be reconfigured with the correct frame size |
1624 // as quickly as possible. | 1623 // as quickly as possible. |
1625 encoder_sink_->OnFrame(video_frame); | 1624 encoder_sink_->OnFrame(video_frame); |
1626 } | 1625 } |
1627 | 1626 |
1628 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( | 1627 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( |
1629 bool enable, | 1628 bool enable, |
1630 const VideoOptions* options, | 1629 const VideoOptions* options, |
1631 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { | 1630 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
1632 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); | 1631 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); |
1633 RTC_DCHECK_RUN_ON(&thread_checker_); | 1632 RTC_DCHECK_RUN_ON(&thread_checker_); |
1634 | 1633 |
1635 // Ignore |options| pointer if |enable| is false. | 1634 // Ignore |options| pointer if |enable| is false. |
1636 bool options_present = enable && options; | 1635 bool options_present = enable && options; |
1637 bool source_changing = source_ != source; | 1636 bool source_changing = source_ != source; |
1638 | 1637 |
1639 if (options_present) { | 1638 if (options_present) { |
1640 VideoOptions old_options = parameters_.options; | 1639 VideoOptions old_options = parameters_.options; |
1641 parameters_.options.SetAll(*options); | 1640 parameters_.options.SetAll(*options); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 } | 2376 } |
2378 | 2377 |
2379 sink_->OnFrame(frame); | 2378 sink_->OnFrame(frame); |
2380 } | 2379 } |
2381 | 2380 |
2382 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { | 2381 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { |
2383 return default_stream_; | 2382 return default_stream_; |
2384 } | 2383 } |
2385 | 2384 |
2386 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( | 2385 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( |
2387 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 2386 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
2388 rtc::CritScope crit(&sink_lock_); | 2387 rtc::CritScope crit(&sink_lock_); |
2389 sink_ = sink; | 2388 sink_ = sink; |
2390 } | 2389 } |
2391 | 2390 |
2392 std::string | 2391 std::string |
2393 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( | 2392 WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetCodecNameFromPayloadType( |
2394 int payload_type) { | 2393 int payload_type) { |
2395 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { | 2394 for (const webrtc::VideoReceiveStream::Decoder& decoder : config_.decoders) { |
2396 if (decoder.payload_type == payload_type) { | 2395 if (decoder.payload_type == payload_type) { |
2397 return decoder.payload_name; | 2396 return decoder.payload_name; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 rtx_mapping[video_codecs[i].codec.id] != | 2559 rtx_mapping[video_codecs[i].codec.id] != |
2561 ulpfec_config.red_payload_type) { | 2560 ulpfec_config.red_payload_type) { |
2562 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2561 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2563 } | 2562 } |
2564 } | 2563 } |
2565 | 2564 |
2566 return video_codecs; | 2565 return video_codecs; |
2567 } | 2566 } |
2568 | 2567 |
2569 } // namespace cricket | 2568 } // namespace cricket |
OLD | NEW |