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 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1507 cpu_restricted_counter_(0), | 1507 cpu_restricted_counter_(0), |
1508 number_of_cpu_adapt_changes_(0), | 1508 number_of_cpu_adapt_changes_(0), |
1509 source_(nullptr), | 1509 source_(nullptr), |
1510 external_encoder_factory_(external_encoder_factory), | 1510 external_encoder_factory_(external_encoder_factory), |
1511 stream_(nullptr), | 1511 stream_(nullptr), |
1512 parameters_(config, options, max_bitrate_bps, codec_settings), | 1512 parameters_(config, options, max_bitrate_bps, codec_settings), |
1513 rtp_parameters_(CreateRtpParametersWithOneEncoding()), | 1513 rtp_parameters_(CreateRtpParametersWithOneEncoding()), |
1514 pending_encoder_reconfiguration_(false), | 1514 pending_encoder_reconfiguration_(false), |
1515 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), | 1515 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
1516 sending_(false), | 1516 sending_(false), |
1517 first_frame_timestamp_ms_(0), | 1517 first_frame_timestamp_valid_(false), |
perkj_webrtc
2016/04/13 05:57:06
why this change?
nisse-webrtc
2016/04/13 06:54:50
Zero is a valid timestamp offset, we need a separa
pbos-webrtc
2016/04/13 09:56:24
Sounds like we should use rtc::Optional then, or a
nisse-webrtc
2016/04/13 11:30:47
Done. Is it correct to rely on the default constru
| |
1518 last_frame_timestamp_ms_(0) { | 1518 last_frame_timestamp_ms_(0) { |
1519 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1519 parameters_.config.rtp.max_packet_size = kVideoMtu; |
1520 parameters_.conference_mode = send_params.conference_mode; | 1520 parameters_.conference_mode = send_params.conference_mode; |
1521 | 1521 |
1522 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); | 1522 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
1523 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1523 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1524 ¶meters_.config.rtp.rtx.ssrcs); | 1524 ¶meters_.config.rtp.rtx.ssrcs); |
1525 parameters_.config.rtp.c_name = sp.cname; | 1525 parameters_.config.rtp.c_name = sp.cname; |
1526 parameters_.config.rtp.extensions = rtp_extensions; | 1526 parameters_.config.rtp.extensions = rtp_extensions; |
1527 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size | 1527 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1566 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); | 1566 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); |
1567 webrtc::VideoFrame video_frame(frame.GetVideoFrameBuffer(), 0, 0, | 1567 webrtc::VideoFrame video_frame(frame.GetVideoFrameBuffer(), 0, 0, |
1568 frame.GetVideoRotation()); | 1568 frame.GetVideoRotation()); |
1569 rtc::CritScope cs(&lock_); | 1569 rtc::CritScope cs(&lock_); |
1570 if (stream_ == NULL) { | 1570 if (stream_ == NULL) { |
1571 // Frame input before send codecs are configured, dropping frame. | 1571 // Frame input before send codecs are configured, dropping frame. |
1572 return; | 1572 return; |
1573 } | 1573 } |
1574 | 1574 |
1575 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; | 1575 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
1576 | |
1576 // frame->GetTimeStamp() is essentially a delta, align to webrtc time | 1577 // frame->GetTimeStamp() is essentially a delta, align to webrtc time |
1577 if (first_frame_timestamp_ms_ == 0) { | 1578 if (!first_frame_timestamp_valid_) { |
1578 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; | 1579 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; |
1580 first_frame_timestamp_valid_ = true; | |
1579 } | 1581 } |
1580 | 1582 |
1581 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; | 1583 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; |
1584 | |
1582 video_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1585 video_frame.set_render_time_ms(last_frame_timestamp_ms_); |
1583 // Reconfigure codec if necessary. | 1586 // Reconfigure codec if necessary. |
1584 SetDimensions(video_frame.width(), video_frame.height()); | 1587 SetDimensions(video_frame.width(), video_frame.height()); |
1585 last_rotation_ = video_frame.rotation(); | 1588 last_rotation_ = video_frame.rotation(); |
1586 | 1589 |
1587 // Not sending, abort after reconfiguration. Reconfiguration should still | 1590 // Not sending, abort after reconfiguration. Reconfiguration should still |
1588 // occur to permit sending this input as quickly as possible once we start | 1591 // occur to permit sending this input as quickly as possible once we start |
1589 // sending (without having to reconfigure then). | 1592 // sending (without having to reconfigure then). |
1590 if (!sending_) { | 1593 if (!sending_) { |
1591 return; | 1594 return; |
1592 } | 1595 } |
1593 | 1596 |
1594 stream_->Input()->IncomingCapturedFrame(video_frame); | 1597 stream_->Input()->IncomingCapturedFrame(video_frame); |
1595 } | 1598 } |
1596 | 1599 |
1597 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( | 1600 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( |
1598 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { | 1601 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
1599 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); | 1602 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); |
1600 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1603 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1601 | 1604 |
1602 if (!source && !source_) | 1605 if (!source && !source_) |
1603 return; | 1606 return; |
1604 DisconnectSource(); | 1607 DisconnectSource(); |
1605 | 1608 |
1606 { | 1609 { |
1607 rtc::CritScope cs(&lock_); | 1610 rtc::CritScope cs(&lock_); |
1608 | 1611 |
1609 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A | 1612 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A |
1610 // new capturer may have a different timestamp delta than the previous one. | 1613 // new capturer may have a different timestamp delta than the previous one. |
1611 first_frame_timestamp_ms_ = 0; | 1614 first_frame_timestamp_valid_ = false; |
1612 | 1615 |
1613 if (source == NULL) { | 1616 if (source == NULL) { |
1614 if (stream_ != NULL) { | 1617 if (stream_ != NULL) { |
1615 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; | 1618 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; |
1616 webrtc::VideoFrame black_frame; | 1619 webrtc::VideoFrame black_frame; |
1617 | 1620 |
1618 CreateBlackFrame(&black_frame, last_dimensions_.width, | 1621 CreateBlackFrame(&black_frame, last_dimensions_.width, |
1619 last_dimensions_.height, last_rotation_); | 1622 last_dimensions_.height, last_rotation_); |
1620 | 1623 |
1621 // Force this black frame not to be dropped due to timestamp order | 1624 // Force this black frame not to be dropped due to timestamp order |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2567 rtx_mapping[video_codecs[i].codec.id] != | 2570 rtx_mapping[video_codecs[i].codec.id] != |
2568 fec_settings.red_payload_type) { | 2571 fec_settings.red_payload_type) { |
2569 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2572 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2570 } | 2573 } |
2571 } | 2574 } |
2572 | 2575 |
2573 return video_codecs; | 2576 return video_codecs; |
2574 } | 2577 } |
2575 | 2578 |
2576 } // namespace cricket | 2579 } // namespace cricket |
OLD | NEW |