mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Rename RtspMessageChannel.openSocket() to open().
The method openSocket in RtspMessageChannel does not actually open a socket. The 'open' term refers more to opening the message channel. #minor-release PiperOrigin-RevId: 375908999
This commit is contained in:
parent
b10f4363b9
commit
f49c14479e
@ -140,7 +140,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
*/
|
||||
public void start() throws IOException {
|
||||
try {
|
||||
messageChannel.openSocket(openSocket());
|
||||
messageChannel.open(getSocket(uri));
|
||||
} catch (IOException e) {
|
||||
Util.closeQuietly(messageChannel);
|
||||
throw e;
|
||||
@ -148,13 +148,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
messageSender.sendOptionsRequest(uri, sessionId);
|
||||
}
|
||||
|
||||
/** Opens a {@link Socket} to the session {@link #uri}. */
|
||||
private Socket openSocket() throws IOException {
|
||||
checkArgument(uri.getHost() != null);
|
||||
int rtspPort = uri.getPort() > 0 ? uri.getPort() : DEFAULT_RTSP_PORT;
|
||||
return SocketFactory.getDefault().createSocket(checkNotNull(uri.getHost()), rtspPort);
|
||||
}
|
||||
|
||||
/** Sets the {@link PlaybackEventListener} to receive playback events. */
|
||||
public void setPlaybackEventListener(PlaybackEventListener playbackEventListener) {
|
||||
this.playbackEventListener = playbackEventListener;
|
||||
@ -217,7 +210,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
try {
|
||||
close();
|
||||
messageChannel = new RtspMessageChannel(new MessageListener());
|
||||
messageChannel.openSocket(openSocket());
|
||||
messageChannel.open(getSocket(uri));
|
||||
sessionId = null;
|
||||
} catch (IOException e) {
|
||||
checkNotNull(playbackEventListener).onPlaybackError(new RtspPlaybackException(e));
|
||||
@ -239,6 +232,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
messageSender.sendSetupRequest(loadInfo.getTrackUri(), loadInfo.getTransport(), sessionId);
|
||||
}
|
||||
|
||||
/** Returns a {@link Socket} that is connected to the {@code uri}. */
|
||||
private static Socket getSocket(Uri uri) throws IOException {
|
||||
checkArgument(uri.getHost() != null);
|
||||
int rtspPort = uri.getPort() > 0 ? uri.getPort() : DEFAULT_RTSP_PORT;
|
||||
return SocketFactory.getDefault().createSocket(checkNotNull(uri.getHost()), rtspPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the RTSP server supports the DESCRIBE method.
|
||||
*
|
||||
|
@ -109,9 +109,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*
|
||||
* <p>An RTSP {@link Socket socket} must be constructed, and used to call {@link #openSocket} to
|
||||
* open the connection before being able to send and receive. {@link #close} must be called when
|
||||
* done.
|
||||
* <p>A connected {@link Socket} must be provided in {@link #open} in order to send and receive
|
||||
* RTSP messages. {@link #close} must be called when done, which would also close the socket.
|
||||
*
|
||||
* <p>{@link MessageListener} and {@link InterleavedBinaryDataListener} implementations must not
|
||||
* make assumptions about which thread called their listener methods; and must be thread-safe.
|
||||
@ -132,9 +131,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
* <p>Note: If an {@link IOException} is thrown, callers must still call {@link #close()} to
|
||||
* ensure that any partial effects of the invocation are cleaned up.
|
||||
*
|
||||
* @param socket An accepted {@link Socket}.
|
||||
* @param socket A connected {@link Socket}.
|
||||
*/
|
||||
public void openSocket(Socket socket) throws IOException {
|
||||
public void open(Socket socket) throws IOException {
|
||||
this.socket = socket;
|
||||
sender = new Sender(socket.getOutputStream());
|
||||
|
||||
|
@ -128,7 +128,7 @@ public final class RtspMessageChannelTest {
|
||||
rtspMessageChannel.registerInterleavedBinaryDataListener(
|
||||
/* channel= */ 1, data -> receivedInterleavedData.put(1, Bytes.asList(data)));
|
||||
|
||||
rtspMessageChannel.openSocket(clientSideSocket);
|
||||
rtspMessageChannel.open(clientSideSocket);
|
||||
|
||||
RobolectricUtil.runMainLooperUntil(receivingFinished::get);
|
||||
Util.closeQuietly(rtspMessageChannel);
|
||||
|
@ -87,7 +87,7 @@ public final class RtspServer implements Closeable {
|
||||
private void handleNewClientConnected(Socket socket) {
|
||||
try {
|
||||
connectedClient = new RtspMessageChannel(new MessageListener());
|
||||
connectedClient.openSocket(socket);
|
||||
connectedClient.open(socket);
|
||||
} catch (IOException e) {
|
||||
Util.closeQuietly(connectedClient);
|
||||
// Log the error.
|
||||
|
Loading…
x
Reference in New Issue
Block a user