generated from P3TERX/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathexoplayer-test.diff
269 lines (259 loc) · 11.6 KB
/
exoplayer-test.diff
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
diff --git a/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java b/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java
index bd2052f..bd250f7 100644
--- a/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java
+++ b/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java
@@ -16,6 +16,7 @@
package androidx.media3.common;
import android.text.TextUtils;
+import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.media3.common.util.Assertions;
@@ -420,6 +421,7 @@ public final class MimeTypes {
if (codec == null) {
return null;
}
+ Log.d("muziling, getMediaMimeType codec=", codec);
codec = Ascii.toLowerCase(codec.trim());
if (codec.startsWith("avc1") || codec.startsWith("avc3")) {
return MimeTypes.VIDEO_H264;
diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java
index 66ac29c..cfc75e5 100644
--- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java
+++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java
@@ -118,6 +118,7 @@ import java.util.HashMap;
private static final int RTP_STATIC_PAYLOAD_TYPE_PCMA = 8;
private static final int RTP_STATIC_PAYLOAD_TYPE_L16_STEREO = 10;
private static final int RTP_STATIC_PAYLOAD_TYPE_L16_MONO = 11;
+ private static final int RTP_STATIC_PAYLOAD_TYPE_MP2T = 33;
private final String mediaType;
private final int port;
@@ -257,6 +258,12 @@ import java.util.HashMap;
/* mediaEncoding= */ "L16",
/* clockRate= */ 44_100,
/* channelCount= */ 1);
+ case RTP_STATIC_PAYLOAD_TYPE_MP2T:
+ return constructAudioRtpMap(
+ RTP_STATIC_PAYLOAD_TYPE_MP2T,
+ /* mediaEncoding= */ "MP2T",
+ /* clockRate= */ 90_000,
+ /* channelCount= */ 1);
default:
throw new IllegalStateException("Unsupported static paylod type " + rtpPayloadType);
}
diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpDataLoadable.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpDataLoadable.java
index 7f2f959..8622713 100644
--- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpDataLoadable.java
+++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpDataLoadable.java
@@ -19,6 +19,7 @@ package androidx.media3.exoplayer.rtsp;
import static androidx.media3.common.util.Assertions.checkNotNull;
import android.os.Handler;
+import android.util.Log;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
import androidx.media3.common.util.UnstableApi;
@@ -29,6 +30,7 @@ import androidx.media3.extractor.DefaultExtractorInput;
import androidx.media3.extractor.Extractor;
import androidx.media3.extractor.ExtractorOutput;
import androidx.media3.extractor.PositionHolder;
+import androidx.media3.extractor.ts.DefaultTsPayloadReaderFactory.FLAG_ALLOW_NON_IDR_KEYFRAMES;
import java.io.IOException;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@@ -148,7 +150,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (loadCancelled) {
loadCancelled = false;
}
-
+ Log.d("muziling", "load " + rtspMediaTrack.payloadFormat.mediaEncoding);
try {
if (dataChannel == null) {
dataChannel = rtpDataChannelFactory.createAndOpenDataChannel(trackId);
diff --git a/libraries-mp2t/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpMp2tExtractor.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpMp2tExtractor.java
new file mode 100644
index 0000000..9bac7ec
--- /dev/null
+++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpMp2tExtractor.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package androidx.media3.exoplayer.rtsp;
+
+import androidx.media3.exoplayer.rtsp.RtpPacket;
+import androidx.media3.extractor.Extractor;
+import androidx.media3.extractor.ExtractorInput;
+import androidx.media3.extractor.ExtractorOutput;
+import androidx.media3.extractor.PositionHolder;
+import androidx.media3.extractor.ts.DefaultTsPayloadReaderFactory;
+import androidx.media3.extractor.ts.TsExtractor;
+
+import java.io.IOException;
+
+/**
+ * Facilitates the extraction of media samples from media stream formatted as MPEG-2 TS RTP payload
+ */
+public final class RtpMp2tExtractor implements Extractor {
+ private final TsExtractor extractor;
+
+ public RtpMp2tExtractor() {
+ this(0);
+ }
+
+ public RtpMp2tExtractor(@DefaultTsPayloadReaderFactory.Flags int defaultTsPayloadReaderFlags ) {
+ extractor = new TsExtractor(defaultTsPayloadReaderFlags);
+ }
+
+ @Override
+ public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
+ if (RtpPacket.sniffHeader(input) > 0) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void init(ExtractorOutput output) {
+ extractor.init(output);
+ }
+
+ @Override
+ public void seek(long position, long timeUs) {
+ extractor.seek(position, timeUs);
+ }
+
+ @Override
+ public void release() {
+ extractor.release();
+ }
+
+ @Override
+ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException,
+ InterruptedException {
+ int bytesToSkip = RtpPacket.sniffHeader(input);
+
+ if (bytesToSkip > 0) {
+ input.skip(bytesToSkip);
+ }
+
+ return extractor.read(input, seekPosition);
+ }
+
+}
diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPayloadFormat.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPayloadFormat.java
index 92a8fb0..ce5163b 100644
--- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPayloadFormat.java
+++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPayloadFormat.java
@@ -17,6 +17,7 @@ package androidx.media3.exoplayer.rtsp;
import static androidx.media3.common.util.Assertions.checkArgument;
+import android.util.Log;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
import androidx.media3.common.Format;
@@ -56,6 +57,7 @@ public final class RtpPayloadFormat {
public static final String RTP_MEDIA_PCMU = "PCMU";
public static final String RTP_MEDIA_VP8 = "VP8";
public static final String RTP_MEDIA_VP9 = "VP9";
+ public static final String RTP_MEDIA_MP2T = "MP2T";
/** Returns whether the format of a {@link MediaDescription} is supported. */
/* package */ static boolean isFormatSupported(MediaDescription mediaDescription) {
@@ -77,6 +79,7 @@ public final class RtpPayloadFormat {
case RTP_MEDIA_PCMU:
case RTP_MEDIA_VP8:
case RTP_MEDIA_VP9:
+ case RTP_MEDIA_MP2T:
return true;
default:
return false;
@@ -91,6 +94,7 @@ public final class RtpPayloadFormat {
* @throws IllegalArgumentException When the media type is not supported/recognized.
*/
public static String getMimeTypeFromRtpMediaType(String mediaType) {
+ Log.d("muziling", "getMimeTypeFromRtpMediaType=" + mediaType);
switch (Ascii.toUpperCase(mediaType)) {
case RTP_MEDIA_AC3:
return MimeTypes.AUDIO_AC3;
@@ -114,6 +118,7 @@ public final class RtpPayloadFormat {
case RTP_MEDIA_H263_2000:
return MimeTypes.VIDEO_H263;
case RTP_MEDIA_H264:
+ case RTP_MEDIA_MP2T:
return MimeTypes.VIDEO_H264;
case RTP_MEDIA_H265:
return MimeTypes.VIDEO_H265;
diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java
index 468c635..3c1d263 100644
--- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java
+++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java
@@ -28,6 +28,7 @@ import static androidx.media3.exoplayer.rtsp.SessionDescription.ATTR_CONTROL;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
+import android.util.Log;
import android.util.Pair;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@@ -171,14 +172,25 @@ import com.google.common.collect.ImmutableMap;
*/
public RtspMediaTrack(
RtspHeaders rtspHeaders, MediaDescription mediaDescription, Uri sessionUri) {
+ try {
checkArgument(
mediaDescription.attributes.containsKey(ATTR_CONTROL), "missing attribute control");
+ } catch (Exception e) {
+ getRootCauseMessage(e);
+ throw e;
+ }
payloadFormat = generatePayloadFormat(mediaDescription);
uri =
extractTrackUri(
rtspHeaders, sessionUri, castNonNull(mediaDescription.attributes.get(ATTR_CONTROL)));
}
-
+ private void getRootCauseMessage(Throwable th) {
+ for (int i=0; i<10; i++) {
+ if (th.getCause() == null) break;
+ else th = th.getCause();
+ }
+ th.printStackTrace();
+ }
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
@@ -222,6 +234,7 @@ import com.google.common.collect.ImmutableMap;
}
ImmutableMap<String, String> fmtpParameters = mediaDescription.getFmtpParametersAsMap();
+ Log.d("muziling", "generatePayloadFormat=" + mimeType);
switch (mimeType) {
case MimeTypes.AUDIO_AAC:
checkArgument(channelCount != C.INDEX_UNSET);
diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/DefaultRtpPayloadReaderFactory.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/DefaultRtpPayloadReaderFactory.java
index 63883dc..e7a9d14 100644
--- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/DefaultRtpPayloadReaderFactory.java
+++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/DefaultRtpPayloadReaderFactory.java
@@ -18,6 +18,7 @@ package androidx.media3.exoplayer.rtsp.reader;
import static androidx.media3.common.util.Assertions.checkNotNull;
+import android.util.Log;
import androidx.annotation.Nullable;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.util.UnstableApi;
@@ -31,6 +32,7 @@ import androidx.media3.exoplayer.rtsp.RtpPayloadFormat;
@Override
@Nullable
public RtpPayloadReader createPayloadReader(RtpPayloadFormat payloadFormat) {
+ Log.d("muziling", "createPayloadReader=" + payloadFormat.format.sampleMimeType);
switch (checkNotNull(payloadFormat.format.sampleMimeType)) {
case MimeTypes.AUDIO_AC3:
return new RtpAc3Reader(payloadFormat);