use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class PublishStreamManagerTest method publishToManager.
private void publishToManager(String url) {
R5Configuration config = new R5Configuration(R5StreamProtocol.RTSP, url, TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("publish_buffer_time"));
config.setLicenseKey(TestContent.GetPropertyString("license_key"));
config.setBundleID(getActivity().getPackageName());
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
publish = new R5Stream(connection);
publish.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
publish.setListener(this);
// show all logging
publish.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
R5Camera camera = null;
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.publish(TestContent.GetPropertyString("stream1"), R5Stream.RecordType.Live);
if (TestContent.GetPropertyBool("video_on"))
cam.startPreview();
edgeShow = new TextView(preview.getContext());
FrameLayout.LayoutParams position = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
edgeShow.setLayoutParams(position);
((FrameLayout) preview.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 SubscribeService method startSubscribe.
public void startSubscribe() {
if (subscribe != null) {
subscribe.stop();
}
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(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);
if (display != null) {
attachDisplay();
}
subscribe.audioController = new R5AudioController();
subscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
subscribe.play(TestContent.GetPropertyString("stream1"));
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class SubscribeNoViewTest method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// 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);
subscribe.setListener(this);
subscribe.audioController = new R5AudioController();
subscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
// show all logging
subscribe.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
subscribe.play(TestContent.GetPropertyString("stream1"));
return super.onCreateView(inflater, container, savedInstanceState);
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class PublishABRTest method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.publish_test, container, false);
// 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(getActivity().getPackageName());
R5Connection connection = new R5Connection(config);
// setup a new stream using the connection
publish = new R5Stream(connection);
publish.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
publish.setListener(this);
// show all logging
publish.setLogLevel(R5Stream.LOG_LEVEL_DEBUG);
R5Camera camera = null;
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);
}
R5AdaptiveBitrateController adaptor = new R5AdaptiveBitrateController();
adaptor.AttachStream(publish);
if (TestContent.GetPropertyBool("audio_on")) {
// attach a microphone
R5Microphone mic = new R5Microphone();
publish.attachMic(mic);
}
preview = (R5VideoView) rootView.findViewById(R.id.videoPreview);
preview.attachStream(publish);
if (TestContent.GetPropertyBool("video_on"))
publish.attachCamera(camera);
preview.showDebugView(TestContent.GetPropertyBool("debug_view"));
publish.publish(TestContent.GetPropertyString("stream1"), R5Stream.RecordType.Live);
if (TestContent.GetPropertyBool("video_on"))
cam.startPreview();
return rootView;
}
use of com.red5pro.streaming.R5Stream in project streaming-android by red5pro.
the class SubscribeTwoStreamTest method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.double_view, container, false);
// 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);
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 = (R5VideoView) view.findViewById(R.id.videoView1);
display.attachStream(subscribe);
display.showDebugView(TestContent.GetPropertyString("debug_view").equals("true"));
subscribe.play(TestContent.GetPropertyString("stream1"));
secondDisplay = (R5VideoView) view.findViewById(R.id.videoView2);
final R5ConnectionListener listener = this;
final Handler root = new Handler(Looper.getMainLooper());
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(4000);
Looper.prepare();
root.post(new Runnable() {
@Override
public void run() {
R5Configuration config2 = new R5Configuration(R5StreamProtocol.RTSP, TestContent.GetPropertyString("host"), TestContent.GetPropertyInt("port"), TestContent.GetPropertyString("context"), TestContent.GetPropertyFloat("subscribe_buffer_time"));
config2.setLicenseKey(TestContent.GetPropertyString("license_key"));
config2.setBundleID(getActivity().getPackageName());
R5Connection secondConnection = new R5Connection(config2);
secondSubscribe = new R5Stream(secondConnection);
secondSubscribe.setListener(listener);
secondDisplay.attachStream(secondSubscribe);
secondDisplay.showDebugView(TestContent.GetPropertyString("debug_view").equals("true"));
secondSubscribe.audioController = new R5AudioController();
secondSubscribe.audioController.sampleRate = TestContent.GetPropertyInt("sample_rate");
secondSubscribe.play(TestContent.GetPropertyString("stream2"));
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
return view;
}
Aggregations