use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class SubscribeStreamManagerTest method subscribeToManager.
private void subscribeToManager(String url) {
// Create the configuration from the tests.xml
R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, url, TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
config.setLicenseKey(TestContent.GetPropertyString("license_key"));
config.setBundleID(getActivity().getPackageName());
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
subscribe = new R5Stream(connection);
subscribe.setListener(this);
subscribe.audioController = new R5AudioController();
subscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
// show all logging
subscribe.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
// find the view and attach the stream
display.attachStream(subscribe);
display.showDebugView(TestContent.GetPropertyBool("debug_view"));
subscribe.play(TestContent.GetPropertyString("stream1"));
edgeShow = new TextView(display.getContext());
FrameLayout.LayoutParams position = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
edgeShow.setLayoutParams(position);
((FrameLayout) display.getParent()).addView(edgeShow);
edgeShow.setText("Connected to: " + url, TextView.BufferType.NORMAL);
edgeShow.setBackgroundColor(Color.LTGRAY);
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class SubscribeTest method Subscribe.
public void Subscribe() {
// Create the configuration from the tests.xml
R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
config.setLicenseKey(TestContent.GetPropertyString("license_key"));
config.setBundleID(getActivity().getPackageName());
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
subscribe = new R5Stream(connection);
// Some devices can't handle rapid reuse of the audio controller, and will crash
// Recreation of the controller assures that the example will always be stable
subscribe.audioController = new R5AudioController();
subscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
subscribe.client = this;
subscribe.setListener(this);
// show all logging
subscribe.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
// display.setZOrderOnTop(true);
display.attachStream(subscribe);
display.showDebugView(TestContent.GetPropertyBool("debug_view"));
subscribe.play(TestContent.GetPropertyString("stream1"));
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class TwoWayTest method onSubscribeReady.
private void onSubscribeReady() {
if (subscribe != null)
return;
System.out.println("bitrate - subscribe start");
Handler r = new Handler(Looper.getMainLooper());
final R5ConnectionListener additionalListener = this;
r.post(new Runnable() {
@Override
public void run() {
System.out.println("Subscribing");
R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
config.setLicenseKey(TestContent.GetPropertyString("license_key"));
config.setBundleID(getActivity().getPackageName());
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
subscribe = new R5Stream(connection);
// show all logging
subscribe.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
// find the view and attach the stream
display.attachStream(subscribe);
display.showDebugView(TestContent.GetPropertyBool("debug_view"));
R5ConnectionListener listener = new R5ConnectionListener() {
@Override
public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {
// additionalListener.onConnectionEvent(r5ConnectionEvent);
Log.d("Subscriber", ":onConnectionEvent " + r5ConnectionEvent.name());
if (r5ConnectionEvent == R5ConnectionEvent.START_STREAMING) {
isSubscribing = true;
}
if (r5ConnectionEvent == R5ConnectionEvent.ERROR) {
subscribe.stop();
subscribe = null;
isSubscribing = false;
sendRemoteCall();
}
if (r5ConnectionEvent == R5ConnectionEvent.DISCONNECTED) {
if (isSubscribing) {
isSubscribing = false;
subscribe.stop();
subscribe = null;
}
}
}
};
subscribe.setListener(listener);
// Unlike basic subscription, two-way needs echo cancellation, which needs the subscriber and publisher
// to use the same Audio Controller - instead of recreating it for stability, we delay the subscriber
subscribe.play(TestContent.GetPropertyString("stream2"));
killListThread();
}
});
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class PublishTest method publish.
protected void publish() {
String b = getActivity().getPackageName();
// Create the configuration from the values.xml
R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("publish_buffer_time"));
config.setLicenseKey(TestContent.GetPropertyString("license_key"));
config.setBundleID(b);
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
publish = new R5Stream(connection);
publish.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
// show all logging
publish.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
if (TestContent.GetPropertyBool("video_on")) {
// attach a camera video source
cam = openFrontFacingCameraGingerbread();
cam.setDisplayOrientation((camOrientation + 180) % 360);
camera = new R5Camera(cam, TestContent.GetPropertyInt("camera_width"), TestContent.GetPropertyInt("camera_height"));
camera.setBitrate(TestContent.GetPropertyInt("bitrate"));
camera.setOrientation(camOrientation);
camera.setFramerate(TestContent.GetPropertyInt("fps"));
}
if (TestContent.GetPropertyBool("audio_on")) {
// attach a microphone
R5Microphone mic = new R5Microphone();
publish.attachMic(mic);
}
preview.attachStream(publish);
if (TestContent.GetPropertyBool("video_on"))
publish.attachCamera(camera);
preview.showDebugView(TestContent.GetPropertyBool("debug_view"));
publish.setListener(this);
publish.publish(TestContent.GetPropertyString("stream1"), R5Stream.RecordType.Live);
if (TestContent.GetPropertyBool("video_on")) {
cam.startPreview();
}
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class SubscribeCluster method beginSubscribe.
protected void beginSubscribe() {
R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, edgeIP, TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
config.setLicenseKey(TestContent.GetPropertyString("license_key"));
config.setBundleID(getActivity().getPackageName());
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
subscribe = new R5Stream(connection);
subscribe.setListener(this);
subscribe.audioController = new R5AudioController();
subscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
// show all logging
subscribe.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
// find the view and attach the stream
display.attachStream(subscribe);
display.showDebugView(TestContent.GetPropertyBool("debug_view"));
subscribe.play(TestContent.GetPropertyString("stream1"));
edgeShow = new TextView(display.getContext());
FrameLayout.LayoutParams position = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
edgeShow.setLayoutParams(position);
((FrameLayout) display.getParent()).addView(edgeShow);
edgeShow.setText("Connected to: " + edgeIP, TextView.BufferType.NORMAL);
edgeShow.setBackgroundColor(Color.LTGRAY);
}
Aggregations