webrtc_m130/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
4.3 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h"
#include <assert.h>
#include <string.h>
#include <memory>
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/trace_event.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
namespace webrtc {
RTPReceiverStrategy* RTPReceiverStrategy::CreateVideoStrategy(
RtpData* data_callback) {
return new RTPReceiverVideo(data_callback);
}
RTPReceiverVideo::RTPReceiverVideo(RtpData* data_callback)
: RTPReceiverStrategy(data_callback) {
}
RTPReceiverVideo::~RTPReceiverVideo() {
}
bool RTPReceiverVideo::ShouldReportCsrcChanges(uint8_t payload_type) const {
// Always do this for video packets.
return true;
}
int32_t RTPReceiverVideo::OnNewPayloadTypeCreated(
const CodecInst& audio_codec) {
RTC_NOTREACHED();
return 0;
}
int32_t RTPReceiverVideo::ParseRtpPacket(WebRtcRTPHeader* rtp_header,
const PayloadUnion& specific_payload,
bool is_red,
const uint8_t* payload,
size_t payload_length,
int64_t timestamp_ms,
bool is_first_packet) {
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "Video::ParseRtp",
"seqnum", rtp_header->header.sequenceNumber, "timestamp",
rtp_header->header.timestamp);
rtp_header->type.Video.codec = specific_payload.Video.videoCodecType;
RTC_DCHECK_GE(payload_length, rtp_header->header.paddingLength);
const size_t payload_data_length =
payload_length - rtp_header->header.paddingLength;
if (payload == NULL || payload_data_length == 0) {
return data_callback_->OnReceivedPayloadData(NULL, 0, rtp_header) == 0 ? 0
: -1;
}
if (first_packet_received_()) {
LOG(LS_INFO) << "Received first video RTP packet";
}
// We are not allowed to hold a critical section when calling below functions.
std::unique_ptr<RtpDepacketizer> depacketizer(
RtpDepacketizer::Create(rtp_header->type.Video.codec));
if (depacketizer.get() == NULL) {
LOG(LS_ERROR) << "Failed to create depacketizer.";
return -1;
}
Reland of Rename RTPVideoHeader.isFirstPacket to .is_first_packet_in_frame. Add RTC_DEPRACATed anonymous unions to not break downstream projects. Orignal issue's description: > commit 0ad21111fcc57a7e978edba3c4263f0062d7f9ff > Author: danilchap <danilchap@webrtc.org> > Date: Mon Dec 19 09:36:33 2016 -0800 > > Revert of Rename RTPVideoHeader.isFirstPacket to > .is_first_packet_in_frame. (patchset #1 id:1 of > https://codereview.webrtc.org/2574943003/ ) > > Reason for revert: > breaks downstream project. > > Can you make this change in a compatible way using anonymous > union: > union { > bool is_first_packet_in_frame; > RTC_DEPRECATED bool isFirstPacket; > }; > (unfortunetly this this treak breaks braced initialization in > rtp_rtcp_impl_unittest.cc, > so that should be rewritting in a more classic way) > > Original issue's description: > > Rename RTPVideoHeader.isFirstPacket to > > .is_first_packet_in_frame. > > > > Name should represent the actual meaning. > > > > BUG=None > > > > Review-Url: https://codereview.webrtc.org/2574943003 > > Cr-Commit-Position: refs/heads/master@{#15684} > > Committed: > > https://chromium.googlesource.com/external/webrtc/+/efde90838055f44ca05863ba020ca02c88b6d14c > > TBR=stefan@webrtc.org,sprang@webrtc.org,johan@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days > ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=None > > Review-Url: https://codereview.webrtc.org/2589783003 > Cr-Commit-Position: refs/heads/master@{#15686} > BUG=None Review-Url: https://codereview.webrtc.org/2614503002 Cr-Commit-Position: refs/heads/master@{#15987}
2017-01-10 04:21:35 -08:00
rtp_header->type.Video.is_first_packet_in_frame = is_first_packet;
RtpDepacketizer::ParsedPayload parsed_payload;
if (!depacketizer->Parse(&parsed_payload, payload, payload_data_length))
return -1;
rtp_header->frameType = parsed_payload.frame_type;
rtp_header->type = parsed_payload.type;
rtp_header->type.Video.rotation = kVideoRotation_0;
// Retrieve the video rotation information.
if (rtp_header->header.extension.hasVideoRotation) {
Reland of Ignore Camera and Flip bits in CVO when parsing video rotation (patchset #1 id:1 of https://codereview.webrtc.org/2300323002/ ) Reason for revert: Downstream build is fixed. Original issue's description: > Revert of Ignore Camera and Flip bits in CVO when parsing video rotation (patchset #3 id:80001 of https://codereview.webrtc.org/2280703002/ ) > > Reason for revert: > Breaks downstream build. > > Original issue's description: > > Ignore Camera and Flip bits in CVO when parsing video rotation > > > > Currently, if WebRTC receives a CVO byte where the Camera or Flip bit is > > set, then rotation is incorrectly parsed as 0. This CL fixes that issue. > > The Camera and Flip bit is still unimplemented and will just be ignored > > though. > > > > BUG=webrtc:6120 > > R=danilchap@webrtc.org, pthatcher@webrtc.org, tommi@webrtc.org > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/f9e1b922ef3e0cbe70953dfb7a1d4cb2c44a49e3 > > TBR=pthatcher@webrtc.org,danilchap@webrtc.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6120 > > Committed: https://crrev.com/97667c7746282704acccd896e26175decee349c0 > Cr-Commit-Position: refs/heads/master@{#14035} TBR=pthatcher@webrtc.org,danilchap@webrtc.org,tommi@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6120 Review-Url: https://codereview.webrtc.org/2320913003 Cr-Commit-Position: refs/heads/master@{#14124}
2016-09-08 03:24:58 -07:00
rtp_header->type.Video.rotation =
rtp_header->header.extension.videoRotation;
}
rtp_header->type.Video.playout_delay =
rtp_header->header.extension.playout_delay;
return data_callback_->OnReceivedPayloadData(parsed_payload.payload,
parsed_payload.payload_length,
rtp_header) == 0
? 0
: -1;
}
RTPAliveType RTPReceiverVideo::ProcessDeadOrAlive(
uint16_t last_payload_length) const {
return kRtpDead;
}
int32_t RTPReceiverVideo::InvokeOnInitializeDecoder(
RtpFeedback* callback,
int8_t payload_type,
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const PayloadUnion& specific_payload) const {
// TODO(pbos): Remove as soon as audio can handle a changing payload type
// without this callback.
return 0;
}
} // namespace webrtc