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

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

Issue 1884863004: Revert of Use microsecond timestamp in cricket::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 * 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
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),
1527 last_frame_timestamp_ms_(0) { 1528 last_frame_timestamp_ms_(0) {
1528 parameters_.config.rtp.max_packet_size = kVideoMtu; 1529 parameters_.config.rtp.max_packet_size = kVideoMtu;
1529 parameters_.conference_mode = send_params.conference_mode; 1530 parameters_.conference_mode = send_params.conference_mode;
1530 1531
1531 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1532 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1532 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1533 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1533 &parameters_.config.rtp.rtx.ssrcs); 1534 &parameters_.config.rtp.rtx.ssrcs);
1534 parameters_.config.rtp.c_name = sp.cname; 1535 parameters_.config.rtp.c_name = sp.cname;
1535 parameters_.config.rtp.extensions = rtp_extensions; 1536 parameters_.config.rtp.extensions = rtp_extensions;
1536 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size 1537 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); 1576 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame");
1576 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, 1577 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0,
1577 frame.rotation()); 1578 frame.rotation());
1578 rtc::CritScope cs(&lock_); 1579 rtc::CritScope cs(&lock_);
1579 if (stream_ == NULL) { 1580 if (stream_ == NULL) {
1580 // Frame input before send codecs are configured, dropping frame. 1581 // Frame input before send codecs are configured, dropping frame.
1581 return; 1582 return;
1582 } 1583 }
1583 1584
1584 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; 1585 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_) { 1587 if (first_frame_timestamp_ms_ == 0) {
1588 first_frame_timestamp_ms_ = 1588 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms;
1589 rtc::Optional<int64_t>(rtc::Time() - frame_delta_ms);
1590 } 1589 }
1591 1590
1592 last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms; 1591 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms;
1593
1594 video_frame.set_render_time_ms(last_frame_timestamp_ms_); 1592 video_frame.set_render_time_ms(last_frame_timestamp_ms_);
1595 // Reconfigure codec if necessary. 1593 // Reconfigure codec if necessary.
1596 SetDimensions(video_frame.width(), video_frame.height()); 1594 SetDimensions(video_frame.width(), video_frame.height());
1597 last_rotation_ = video_frame.rotation(); 1595 last_rotation_ = video_frame.rotation();
1598 1596
1599 // Not sending, abort after reconfiguration. Reconfiguration should still 1597 // Not sending, abort after reconfiguration. Reconfiguration should still
1600 // occur to permit sending this input as quickly as possible once we start 1598 // occur to permit sending this input as quickly as possible once we start
1601 // sending (without having to reconfigure then). 1599 // sending (without having to reconfigure then).
1602 if (!sending_) { 1600 if (!sending_) {
1603 return; 1601 return;
1604 } 1602 }
1605 1603
1606 stream_->Input()->IncomingCapturedFrame(video_frame); 1604 stream_->Input()->IncomingCapturedFrame(video_frame);
1607 } 1605 }
1608 1606
1609 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( 1607 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource(
1610 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { 1608 rtc::VideoSourceInterface<cricket::VideoFrame>* source) {
1611 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); 1609 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource");
1612 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 1610 RTC_DCHECK(thread_checker_.CalledOnValidThread());
1613 1611
1614 if (!source && !source_) 1612 if (!source && !source_)
1615 return; 1613 return;
1616 DisconnectSource(); 1614 DisconnectSource();
1617 1615
1618 { 1616 {
1619 rtc::CritScope cs(&lock_); 1617 rtc::CritScope cs(&lock_);
1620 1618
1621 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A 1619 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A
1622 // new capturer may have a different timestamp delta than the previous one. 1620 // new capturer may have a different timestamp delta than the previous one.
1623 first_frame_timestamp_ms_ = rtc::Optional<int64_t>(); 1621 first_frame_timestamp_ms_ = 0;
1624 1622
1625 if (source == NULL) { 1623 if (source == NULL) {
1626 if (stream_ != NULL) { 1624 if (stream_ != NULL) {
1627 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; 1625 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame.";
1628 webrtc::VideoFrame black_frame; 1626 webrtc::VideoFrame black_frame;
1629 1627
1630 CreateBlackFrame(&black_frame, last_dimensions_.width, 1628 CreateBlackFrame(&black_frame, last_dimensions_.width,
1631 last_dimensions_.height, last_rotation_); 1629 last_dimensions_.height, last_rotation_);
1632 1630
1633 // Force this black frame not to be dropped due to timestamp order 1631 // Force this black frame not to be dropped due to timestamp order
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 2395
2398 if (sink_ == NULL) { 2396 if (sink_ == NULL) {
2399 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink."; 2397 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink.";
2400 return; 2398 return;
2401 } 2399 }
2402 2400
2403 last_width_ = frame.width(); 2401 last_width_ = frame.width();
2404 last_height_ = frame.height(); 2402 last_height_ = frame.height();
2405 2403
2406 const WebRtcVideoFrame render_frame( 2404 const WebRtcVideoFrame render_frame(
2407 frame.video_frame_buffer(), frame.rotation(), 2405 frame.video_frame_buffer(),
2408 frame.render_time_ms() * rtc::kNumNanosecsPerMicrosec); 2406 frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, frame.rotation());
2409 sink_->OnFrame(render_frame); 2407 sink_->OnFrame(render_frame);
2410 } 2408 }
2411 2409
2412 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { 2410 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const {
2413 return default_stream_; 2411 return default_stream_;
2414 } 2412 }
2415 2413
2416 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink( 2414 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetSink(
2417 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { 2415 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
2418 rtc::CritScope crit(&sink_lock_); 2416 rtc::CritScope crit(&sink_lock_);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 rtx_mapping[video_codecs[i].codec.id] != 2577 rtx_mapping[video_codecs[i].codec.id] !=
2580 fec_settings.red_payload_type) { 2578 fec_settings.red_payload_type) {
2581 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2579 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2582 } 2580 }
2583 } 2581 }
2584 2582
2585 return video_codecs; 2583 return video_codecs;
2586 } 2584 }
2587 2585
2588 } // namespace cricket 2586 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698