Better interface

Signed-off-by: Leo Ma <begeekmyfriend@gmail.com>
camera2
Leo Ma 9 years ago
parent bbd0e7df2f
commit 848b0763b9

@ -70,12 +70,13 @@ public class SrsEncoder {
public int start() {
try {
muxer.start(rtmpUrl, VCROP_WIDTH, VCROP_HEIGHT);
muxer.start(rtmpUrl);
} catch (IOException e) {
Log.e(TAG, "start muxer failed.");
e.printStackTrace();
return -1;
}
muxer.setVideoResolution(VCROP_WIDTH, VCROP_HEIGHT);
// the referent PTS for video and audio encoder.
mPresentTimeUs = System.nanoTime() / 1000;

@ -4,14 +4,14 @@ import android.media.MediaCodec;
import android.media.MediaFormat;
import android.util.Log;
import net.ossrs.sea.rtmp.RtmpPublisher;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import net.ossrs.sea.rtmp.RtmpPublisher;
/**
* Created by winlin on 5/2/15.
* Updated by leoma on 4/1/16.
@ -74,7 +74,18 @@ public class SrsFlvMuxer {
* get cached video frame number in publisher
*/
public final AtomicInteger getVideoFrameCacheNumber() {
return publisher.getVideoFrameCacheNumber();
return publisher == null ? null : publisher.getVideoFrameCacheNumber();
}
/**
* set video resolution for publisher
* @param width
* @param height
*/
public void setVideoResolution(int width, int height) {
if (publisher != null) {
publisher.setVideoResolution(width, height);
}
}
/**
@ -134,9 +145,8 @@ public class SrsFlvMuxer {
/**
* start to the remote SRS for remux.
*/
public void start(String url, int width, int height) throws IOException {
public void start(String url) throws IOException {
rtmpUrl = url;
publisher.setVideoResolution(width, height);
worker = new Thread(new Runnable() {
@Override

@ -22,7 +22,6 @@ public class WriteThread extends Thread {
private static final String TAG = "WriteThread";
private RtmpPublisher.EventHandler handler;
private RtmpSessionInfo rtmpSessionInfo;
private OutputStream out;
private ConcurrentLinkedQueue<RtmpPacket> writeQueue = new ConcurrentLinkedQueue<RtmpPacket>();

Loading…
Cancel
Save