mirror of
https://github.com/androidx/media.git
synced 2025-05-12 01:59:50 +08:00
Define the default RTSP character set.
#minor-release PiperOrigin-RevId: 374433331
This commit is contained in:
parent
66c1aedeb3
commit
e383b0031d
@ -40,6 +40,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -47,6 +48,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
/** Sends and receives RTSP messages. */
|
||||
/* package */ final class RtspMessageChannel implements Closeable {
|
||||
|
||||
/** RTSP uses UTF-8 (RFC2326 Section 1.1). */
|
||||
public static final Charset CHARSET = Charsets.UTF_8;
|
||||
|
||||
private static final String TAG = "RtspMessageChannel";
|
||||
|
||||
/** A listener for received RTSP messages and possible failures. */
|
||||
@ -383,8 +387,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
&& lineBytes[lineBytes.length - 2] == Ascii.CR
|
||||
&& lineBytes[lineBytes.length - 1] == Ascii.LF);
|
||||
String line =
|
||||
new String(
|
||||
lineBytes, /* offset= */ 0, /* length= */ lineBytes.length - 2, Charsets.UTF_8);
|
||||
new String(lineBytes, /* offset= */ 0, /* length= */ lineBytes.length - 2, CHARSET);
|
||||
messageLines.add(line);
|
||||
|
||||
switch (state) {
|
||||
|
@ -37,7 +37,6 @@ import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@ -139,7 +138,7 @@ import java.util.regex.Pattern;
|
||||
* removed.
|
||||
*/
|
||||
public static byte[] convertMessageToByteArray(List<String> message) {
|
||||
return Joiner.on("\r\n").join(message).getBytes(Charsets.UTF_8);
|
||||
return Joiner.on("\r\n").join(message).getBytes(RtspMessageChannel.CHARSET);
|
||||
}
|
||||
|
||||
/** Removes the user info from the supplied {@link Uri}. */
|
||||
|
@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.net.Uri;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -219,7 +218,7 @@ public final class RtspMessageUtilTest {
|
||||
|
||||
assertThat(messageLines).isEqualTo(expectedLines);
|
||||
assertThat(RtspMessageUtil.convertMessageToByteArray(messageLines))
|
||||
.isEqualTo(expectedRtspMessage.getBytes(Charsets.UTF_8));
|
||||
.isEqualTo(expectedRtspMessage.getBytes(RtspMessageChannel.CHARSET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -252,7 +251,7 @@ public final class RtspMessageUtilTest {
|
||||
+ "\r\n";
|
||||
assertThat(messageLines).isEqualTo(expectedLines);
|
||||
assertThat(RtspMessageUtil.convertMessageToByteArray(messageLines))
|
||||
.isEqualTo(expectedRtspMessage.getBytes(Charsets.UTF_8));
|
||||
.isEqualTo(expectedRtspMessage.getBytes(RtspMessageChannel.CHARSET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -317,7 +316,7 @@ public final class RtspMessageUtilTest {
|
||||
|
||||
assertThat(messageLines).isEqualTo(expectedLines);
|
||||
assertThat(RtspMessageUtil.convertMessageToByteArray(messageLines))
|
||||
.isEqualTo(expectedRtspMessage.getBytes(Charsets.UTF_8));
|
||||
.isEqualTo(expectedRtspMessage.getBytes(RtspMessageChannel.CHARSET));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -334,7 +333,7 @@ public final class RtspMessageUtilTest {
|
||||
|
||||
assertThat(RtspMessageUtil.serializeResponse(response)).isEqualTo(expectedLines);
|
||||
assertThat(RtspMessageUtil.convertMessageToByteArray(messageLines))
|
||||
.isEqualTo(expectedRtspMessage.getBytes(Charsets.UTF_8));
|
||||
.isEqualTo(expectedRtspMessage.getBytes(RtspMessageChannel.CHARSET));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user