2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-02-05 15:12:39 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h"
|
2011-09-20 13:52:04 +00:00
|
|
|
|
2013-09-06 13:40:11 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <string.h>
|
2013-02-05 15:12:39 +00:00
|
|
|
|
2016-04-27 01:19:58 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2015-07-01 05:35:53 -07:00
|
|
|
#include "webrtc/base/checks.h"
|
2015-10-28 16:39:33 +01:00
|
|
|
#include "webrtc/base/logging.h"
|
2015-10-20 23:00:48 -07:00
|
|
|
#include "webrtc/base/trace_event.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
|
2014-07-31 14:59:24 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
|
2013-03-18 16:39:03 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h"
|
2013-02-05 15:12:39 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
RTPReceiverStrategy* RTPReceiverStrategy::CreateVideoStrategy(
|
2014-04-08 11:06:12 +00:00
|
|
|
RtpData* data_callback) {
|
|
|
|
|
return new RTPReceiverVideo(data_callback);
|
2013-08-15 23:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 11:06:12 +00:00
|
|
|
RTPReceiverVideo::RTPReceiverVideo(RtpData* data_callback)
|
2014-09-12 11:05:55 +00:00
|
|
|
: RTPReceiverStrategy(data_callback) {
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-04-27 05:25:53 +00:00
|
|
|
RTPReceiverVideo::~RTPReceiverVideo() {
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
bool RTPReceiverVideo::ShouldReportCsrcChanges(uint8_t payload_type) const {
|
2013-01-22 12:31:01 +00:00
|
|
|
// Always do this for video packets.
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t RTPReceiverVideo::OnNewPayloadTypeCreated(
|
2013-02-05 15:12:39 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2013-08-15 23:38:54 +00:00
|
|
|
int8_t payload_type,
|
|
|
|
|
uint32_t frequency) {
|
2013-02-04 13:23:07 +00:00
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
int32_t RTPReceiverVideo::ParseRtpPacket(WebRtcRTPHeader* rtp_header,
|
|
|
|
|
const PayloadUnion& specific_payload,
|
|
|
|
|
bool is_red,
|
|
|
|
|
const uint8_t* payload,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t payload_length,
|
2014-09-12 11:05:55 +00:00
|
|
|
int64_t timestamp_ms,
|
|
|
|
|
bool is_first_packet) {
|
2015-02-16 12:06:00 +00:00
|
|
|
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "Video::ParseRtp",
|
|
|
|
|
"seqnum", rtp_header->header.sequenceNumber, "timestamp",
|
2014-09-12 11:05:55 +00:00
|
|
|
rtp_header->header.timestamp);
|
2013-08-15 23:38:54 +00:00
|
|
|
rtp_header->type.Video.codec = specific_payload.Video.videoCodecType;
|
2013-09-08 11:15:00 +00:00
|
|
|
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_GE(payload_length, rtp_header->header.paddingLength);
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
const size_t payload_data_length =
|
2013-09-08 11:15:00 +00:00
|
|
|
payload_length - rtp_header->header.paddingLength;
|
|
|
|
|
|
2014-09-29 08:00:22 +00:00
|
|
|
if (payload == NULL || payload_data_length == 0) {
|
2013-09-08 11:15:00 +00:00
|
|
|
return data_callback_->OnReceivedPayloadData(NULL, 0, rtp_header) == 0 ? 0
|
|
|
|
|
: -1;
|
2014-09-29 08:00:22 +00:00
|
|
|
}
|
2013-09-08 11:15:00 +00:00
|
|
|
|
2016-04-07 15:36:45 -07:00
|
|
|
if (first_packet_received_()) {
|
|
|
|
|
LOG(LS_INFO) << "Received first video RTP packet";
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 11:05:55 +00:00
|
|
|
// We are not allowed to hold a critical section when calling below functions.
|
2016-04-27 01:19:58 -07:00
|
|
|
std::unique_ptr<RtpDepacketizer> depacketizer(
|
2014-09-29 08:00:22 +00:00
|
|
|
RtpDepacketizer::Create(rtp_header->type.Video.codec));
|
2014-09-12 11:05:55 +00:00
|
|
|
if (depacketizer.get() == NULL) {
|
|
|
|
|
LOG(LS_ERROR) << "Failed to create depacketizer.";
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtp_header->type.Video.isFirstPacket = is_first_packet;
|
2014-11-07 11:02:12 +00:00
|
|
|
RtpDepacketizer::ParsedPayload parsed_payload;
|
2014-09-29 08:00:22 +00:00
|
|
|
if (!depacketizer->Parse(&parsed_payload, payload, payload_data_length))
|
|
|
|
|
return -1;
|
|
|
|
|
|
2014-11-07 11:02:12 +00:00
|
|
|
rtp_header->frameType = parsed_payload.frame_type;
|
|
|
|
|
rtp_header->type = parsed_payload.type;
|
2015-04-01 15:33:06 -07:00
|
|
|
rtp_header->type.Video.rotation = kVideoRotation_0;
|
|
|
|
|
|
|
|
|
|
// Retrieve the video rotation information.
|
|
|
|
|
if (rtp_header->header.extension.hasVideoRotation) {
|
|
|
|
|
rtp_header->type.Video.rotation = ConvertCVOByteToVideoRotation(
|
|
|
|
|
rtp_header->header.extension.videoRotation);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 08:00:22 +00:00
|
|
|
return data_callback_->OnReceivedPayloadData(parsed_payload.payload,
|
|
|
|
|
parsed_payload.payload_length,
|
2014-11-07 11:02:12 +00:00
|
|
|
rtp_header) == 0
|
2014-09-29 08:00:22 +00:00
|
|
|
? 0
|
|
|
|
|
: -1;
|
2012-12-18 15:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
int RTPReceiverVideo::GetPayloadTypeFrequency() const {
|
|
|
|
|
return kVideoPayloadTypeFrequency;
|
2012-12-18 15:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RTPAliveType RTPReceiverVideo::ProcessDeadOrAlive(
|
2013-04-08 11:08:41 +00:00
|
|
|
uint16_t last_payload_length) const {
|
2012-12-18 15:40:53 +00:00
|
|
|
return kRtpDead;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t RTPReceiverVideo::InvokeOnInitializeDecoder(
|
2012-12-18 15:40:53 +00:00
|
|
|
RtpFeedback* callback,
|
2013-08-15 23:38:54 +00:00
|
|
|
int8_t payload_type,
|
2013-02-05 15:12:39 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2013-08-15 23:38:54 +00:00
|
|
|
const PayloadUnion& specific_payload) const {
|
2016-02-02 15:40:04 +01:00
|
|
|
// TODO(pbos): Remove as soon as audio can handle a changing payload type
|
|
|
|
|
// without this callback.
|
2012-12-18 15:40:53 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-05 15:12:39 +00:00
|
|
|
} // namespace webrtc
|