| 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 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 cpu_restricted_counter_(0), | 1517 cpu_restricted_counter_(0), |
| 1518 number_of_cpu_adapt_changes_(0), | 1518 number_of_cpu_adapt_changes_(0), |
| 1519 source_(nullptr), | 1519 source_(nullptr), |
| 1520 external_encoder_factory_(external_encoder_factory), | 1520 external_encoder_factory_(external_encoder_factory), |
| 1521 stream_(nullptr), | 1521 stream_(nullptr), |
| 1522 parameters_(config, options, max_bitrate_bps, codec_settings), | 1522 parameters_(config, options, max_bitrate_bps, codec_settings), |
| 1523 rtp_parameters_(CreateRtpParametersWithOneEncoding()), | 1523 rtp_parameters_(CreateRtpParametersWithOneEncoding()), |
| 1524 pending_encoder_reconfiguration_(false), | 1524 pending_encoder_reconfiguration_(false), |
| 1525 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), | 1525 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
| 1526 sending_(false), | 1526 sending_(false), |
| 1527 first_frame_timestamp_ms_(0), | |
| 1528 last_frame_timestamp_ms_(0) { | 1527 last_frame_timestamp_ms_(0) { |
| 1529 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1528 parameters_.config.rtp.max_packet_size = kVideoMtu; |
| 1530 parameters_.conference_mode = send_params.conference_mode; | 1529 parameters_.conference_mode = send_params.conference_mode; |
| 1531 | 1530 |
| 1532 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); | 1531 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
| 1533 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1532 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
| 1534 ¶meters_.config.rtp.rtx.ssrcs); | 1533 ¶meters_.config.rtp.rtx.ssrcs); |
| 1535 parameters_.config.rtp.c_name = sp.cname; | 1534 parameters_.config.rtp.c_name = sp.cname; |
| 1536 parameters_.config.rtp.extensions = rtp_extensions; | 1535 parameters_.config.rtp.extensions = rtp_extensions; |
| 1537 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size | 1536 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); | 1575 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); |
| 1577 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, | 1576 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, |
| 1578 frame.rotation()); | 1577 frame.rotation()); |
| 1579 rtc::CritScope cs(&lock_); | 1578 rtc::CritScope cs(&lock_); |
| 1580 if (stream_ == NULL) { | 1579 if (stream_ == NULL) { |
| 1581 // Frame input before send codecs are configured, dropping frame. | 1580 // Frame input before send codecs are configured, dropping frame. |
| 1582 return; | 1581 return; |
| 1583 } | 1582 } |
| 1584 | 1583 |
| 1585 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; | 1584 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
| 1585 |
| 1586 // frame->GetTimeStamp() is essentially a delta, align to webrtc time | 1586 // frame->GetTimeStamp() is essentially a delta, align to webrtc time |
| 1587 if (first_frame_timestamp_ms_ == 0) { | 1587 if (!first_frame_timestamp_ms_) { |
| 1588 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; | 1588 first_frame_timestamp_ms_ = |
| 1589 rtc::Optional<int64_t>(rtc::Time() - frame_delta_ms); |
| 1589 } | 1590 } |
| 1590 | 1591 |
| 1591 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; | 1592 last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms; |
| 1593 |
| 1592 video_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1594 video_frame.set_render_time_ms(last_frame_timestamp_ms_); |
| 1593 // Reconfigure codec if necessary. | 1595 // Reconfigure codec if necessary. |
| 1594 SetDimensions(video_frame.width(), video_frame.height()); | 1596 SetDimensions(video_frame.width(), video_frame.height()); |
| 1595 last_rotation_ = video_frame.rotation(); | 1597 last_rotation_ = video_frame.rotation(); |
| 1596 | 1598 |
| 1597 // Not sending, abort after reconfiguration. Reconfiguration should still | 1599 // Not sending, abort after reconfiguration. Reconfiguration should still |
| 1598 // occur to permit sending this input as quickly as possible once we start | 1600 // occur to permit sending this input as quickly as possible once we start |
| 1599 // sending (without having to reconfigure then). | 1601 // sending (without having to reconfigure then). |
| 1600 if (!sending_) { | 1602 if (!sending_) { |
| 1601 return; | 1603 return; |
| 1602 } | 1604 } |
| 1603 | 1605 |
| 1604 stream_->Input()->IncomingCapturedFrame(video_frame); | 1606 stream_->Input()->IncomingCapturedFrame(video_frame); |
| 1605 } | 1607 } |
| 1606 | 1608 |
| 1607 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( | 1609 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( |
| 1608 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { | 1610 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
| 1609 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); | 1611 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); |
| 1610 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1612 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1611 | 1613 |
| 1612 if (!source && !source_) | 1614 if (!source && !source_) |
| 1613 return; | 1615 return; |
| 1614 DisconnectSource(); | 1616 DisconnectSource(); |
| 1615 | 1617 |
| 1616 { | 1618 { |
| 1617 rtc::CritScope cs(&lock_); | 1619 rtc::CritScope cs(&lock_); |
| 1618 | 1620 |
| 1619 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A | 1621 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A |
| 1620 // new capturer may have a different timestamp delta than the previous one. | 1622 // new capturer may have a different timestamp delta than the previous one. |
| 1621 first_frame_timestamp_ms_ = 0; | 1623 first_frame_timestamp_ms_ = rtc::Optional<int64_t>(); |
| 1622 | 1624 |
| 1623 if (source == NULL) { | 1625 if (source == NULL) { |
| 1624 if (stream_ != NULL) { | 1626 if (stream_ != NULL) { |
| 1625 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; | 1627 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; |
| 1626 webrtc::VideoFrame black_frame; | 1628 webrtc::VideoFrame black_frame; |
| 1627 | 1629 |
| 1628 CreateBlackFrame(&black_frame, last_dimensions_.width, | 1630 CreateBlackFrame(&black_frame, last_dimensions_.width, |
| 1629 last_dimensions_.height, last_rotation_); | 1631 last_dimensions_.height, last_rotation_); |
| 1630 | 1632 |
| 1631 // Force this black frame not to be dropped due to timestamp order | 1633 // Force this black frame not to be dropped due to timestamp order |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2395 | 2397 |
| 2396 if (sink_ == NULL) { | 2398 if (sink_ == NULL) { |
| 2397 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink."; | 2399 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink."; |
| 2398 return; | 2400 return; |
| 2399 } | 2401 } |
| 2400 | 2402 |
| 2401 last_width_ = frame.width(); | 2403 last_width_ = frame.width(); |
| 2402 last_height_ = frame.height(); | 2404 last_height_ = frame.height(); |
| 2403 | 2405 |
| 2404 const WebRtcVideoFrame render_frame( | 2406 const WebRtcVideoFrame render_frame( |
| 2405 frame.video_frame_buffer(), | 2407 frame.video_frame_buffer(), frame.rotation(), |
| 2406 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation()); | 2408 frame.render_time_ms() * rtc::kNumNanosecsPerMicrosec); |
| 2407 sink_->OnFrame(render_frame); | 2409 sink_->OnFrame(render_frame); |
| 2408 } | 2410 } |
| 2409 | 2411 |
| 2410 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { | 2412 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { |
| 2411 return default_stream_; | 2413 return default_stream_; |
| 2412 } | 2414 } |
| 2413 | 2415 |
| 2414 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( | 2416 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( |
| 2415 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { | 2417 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
| 2416 rtc::CritScope crit(&sink_lock_); | 2418 rtc::CritScope crit(&sink_lock_); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 rtx_mapping[video_codecs[i].codec.id] != | 2579 rtx_mapping[video_codecs[i].codec.id] != |
| 2578 fec_settings.red_payload_type) { | 2580 fec_settings.red_payload_type) { |
| 2579 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2581 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2580 } | 2582 } |
| 2581 } | 2583 } |
| 2582 | 2584 |
| 2583 return video_codecs; | 2585 return video_codecs; |
| 2584 } | 2586 } |
| 2585 | 2587 |
| 2586 } // namespace cricket | 2588 } // namespace cricket |
| OLD | NEW |