use of com.red5pro.streaming.source.R5Camera in project streaming-android by red5pro.
the class PublishHQAudioTest method publish.
@Override
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();
// kbps
mic.setBitRate(128);
// hz (samples/second)
R5AudioController.getInstance().sampleRate = 44100;
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.source.R5Camera in project streaming-android by red5pro.
the class SharedObjectTest method onStop.
@Override
public void onStop() {
if (callThread != null) {
callThread.interrupt();
callThread = null;
}
if (sObject != null) {
if (sObject.getData().has("count")) {
try {
sObject.setProperty("count", sObject.getData().getInt("count") - 1);
} catch (JSONException e) {
e.printStackTrace();
}
}
sObject.close();
sObject.client = null;
sObject = null;
}
if (stream != null) {
stream.setListener(null);
stream.stop();
if (stream.getVideoSource() != null) {
Camera c = ((R5Camera) stream.getVideoSource()).getCamera();
c.stopPreview();
c.release();
}
stream = null;
if (publish != null)
publish = null;
}
super.onStop();
}
Aggregations