blob: 6ab389ebdbeb00790a6e21e9a8af254afd1f4cd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cast/streaming/rtp_defines.h"
#include "util/osp_logging.h"
namespace openscreen {
namespace cast {
RtpPayloadType GetPayloadType(AudioCodec codec, bool use_android_rtp_hack) {
if (use_android_rtp_hack) {
return codec == AudioCodec::kNotSpecified
? RtpPayloadType::kAudioVarious
: RtpPayloadType::kAudioHackForAndroidTV;
}
switch (codec) {
case AudioCodec::kAac:
return RtpPayloadType::kAudioAac;
case AudioCodec::kOpus:
return RtpPayloadType::kAudioOpus;
case AudioCodec::kNotSpecified:
return RtpPayloadType::kAudioVarious;
default:
OSP_NOTREACHED();
}
}
RtpPayloadType GetPayloadType(VideoCodec codec, bool use_android_rtp_hack) {
if (use_android_rtp_hack) {
return codec == VideoCodec::kNotSpecified
? RtpPayloadType::kVideoVarious
: RtpPayloadType::kVideoHackForAndroidTV;
}
switch (codec) {
// VP8 and VP9 share the same payload type.
case VideoCodec::kVp9:
case VideoCodec::kVp8:
return RtpPayloadType::kVideoVp8;
// H264 and HEVC/H265 share the same payload type.
case VideoCodec::kHevc: // fallthrough
case VideoCodec::kH264:
return RtpPayloadType::kVideoH264;
case VideoCodec::kAv1:
return RtpPayloadType::kVideoAv1;
case VideoCodec::kNotSpecified:
return RtpPayloadType::kVideoVarious;
default:
OSP_NOTREACHED();
}
}
bool IsRtpPayloadType(uint8_t raw_byte) {
switch (static_cast<RtpPayloadType>(raw_byte)) {
case RtpPayloadType::kAudioOpus:
case RtpPayloadType::kAudioAac:
case RtpPayloadType::kAudioPcm16:
case RtpPayloadType::kAudioVarious:
case RtpPayloadType::kVideoVp8:
case RtpPayloadType::kVideoH264:
case RtpPayloadType::kVideoVp9:
case RtpPayloadType::kVideoAv1:
case RtpPayloadType::kVideoVarious:
case RtpPayloadType::kAudioHackForAndroidTV:
// Note: RtpPayloadType::kVideoHackForAndroidTV has the same value as
// kAudioOpus.
return true;
case RtpPayloadType::kNull:
break;
}
return false;
}
bool IsRtcpPacketType(uint8_t raw_byte) {
switch (static_cast<RtcpPacketType>(raw_byte)) {
case RtcpPacketType::kSenderReport:
case RtcpPacketType::kReceiverReport:
case RtcpPacketType::kSourceDescription:
case RtcpPacketType::kApplicationDefined:
case RtcpPacketType::kPayloadSpecific:
case RtcpPacketType::kExtendedReports:
return true;
case RtcpPacketType::kNull:
break;
}
return false;
}
} // namespace cast
} // namespace openscreen
|