You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4 KiB
Java

package com.github.faucamp.simplertmp;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Simple RTMP publisher, using vanilla Java networking (no NIO)
* This was created primarily to address a NIO bug in Android 2.2 when
* used with Apache Mina, but also to provide an easy-to-use way to access
* RTMP streams
*
* @author francois, leo
*/
public interface RtmpPublisher {
/**
* Issues an RTMP "connect" command and wait for the response.
*
* @param url specify the RTMP url
* @return If succeeded return true else return false
* @throws IOException if a network/IO error occurs
*/
boolean connect(String url) throws IOException;
/**
* Issues an RTMP "publish" command and write the media content stream packets (audio and video).
*
* @param publishType specify the way to publish raw RTMP packets among "live", "record" and "append"
* @return If succeeded return true else return false
* @throws IllegalStateException if the client is not connected to a RTMP server
* @throws IOException if a network/IO error occurs
*/
boolean publish(String publishType) throws IllegalStateException, IOException;
/**
* Stops and closes the current RTMP stream
*/
void closeStream() throws IllegalStateException;
/**
* Shuts down the RTMP client and stops all threads associated with it
*/
void shutdown();
/**
* publish a video content packet to server
*
* @param data video stream byte array
* @param dts video stream decoding timestamp
*/
void publishVideoData(byte[] data, int dts) throws IllegalStateException;
/**
* publish an audio content packet to server
*
* @param data audio stream byte array
* @param dts audio stream decoding timestamp
*/
void publishAudioData(byte[] data, int dts) throws IllegalStateException;
/**
* obtain video frame number cached in publisher
*/
AtomicInteger getVideoFrameCacheNumber();
/**
* obtain the IP address of the peer if any
*/
String getServerIpAddr();
/**
* obtain the PID of the peer if any
*/
int getServerPid();
/**
* obtain the ID of the peer if any
*/
int getServerId();
/**
* set video resolution
*
* @param width
* @param height
*/
void setVideoResolution(int width, int height);
}