use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.
the class TwoWayTest method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.twoway_test, container, false);
preview = (R5VideoView) rootView.findViewById(R.id.videoPreview);
publish();
publish.client = this;
final R5ConnectionListener additionalListener = this;
publish.setListener(new R5ConnectionListener() {
@Override
public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {
additionalListener.onConnectionEvent(r5ConnectionEvent);
if (r5ConnectionEvent == R5ConnectionEvent.START_STREAMING) {
isPublishing = true;
sendRemoteCall();
}
if (r5ConnectionEvent == R5ConnectionEvent.DISCONNECTED) {
if (isSubscribing) {
isSubscribing = false;
subscribe.stop();
subscribe = null;
}
isPublishing = false;
}
}
});
display = (R5VideoView) rootView.findViewById(R.id.videoView);
return rootView;
}
use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.
the class PublishStreamManagerTest method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.publish_test, container, false);
preview = (R5VideoView) rootView.findViewById(R.id.videoPreview);
new Thread(new Runnable() {
@Override
public void run() {
try {
// url format: https://{streammanagerhost}:{port}/streammanager/api/2.0/event/{scopeName}/{streamName}?action=broadcast
String port = TestContent.getFormattedPortSetting(TestContent.GetPropertyString("server_port"));
String url = "http://" + TestContent.GetPropertyString("host") + port + "/streammanager/api/2.0/event/" + TestContent.GetPropertyString("context") + "/" + TestContent.GetPropertyString("stream1") + "?action=broadcast";
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(new HttpGet(url));
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
String responseString = out.toString();
out.close();
JSONObject data = new JSONObject(responseString);
final String outURL = data.getString("serverAddress");
if (!outURL.isEmpty()) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
publishToManager(outURL);
}
});
} else {
System.out.println("Server address not returned");
}
} else {
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
return rootView;
}
use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.
the class SubscribeCluster method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.subscribe_test, container, false);
display = (R5VideoView) view.findViewById(R.id.videoView);
new Thread(new Runnable() {
@Override
public void run() {
try {
HttpClient httpClient = new DefaultHttpClient();
String port = TestContent.getFormattedPortSetting(TestContent.GetPropertyString("server_port"));
HttpResponse response = httpClient.execute(new HttpGet("http://" + TestContent.GetPropertyString("host") + port + "/cluster"));
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
String responseString = out.toString();
out.close();
// the return is the host ip and rtmp port. we are only interested in the host ip.
String[] bits = responseString.split(":");
edgeIP = bits[0];
Log.i("cluster", "round robin ip: " + edgeIP);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
beginSubscribe();
}
});
} else {
// Closes the connection.
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
return view;
}
use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.
the class SubscribeReconnectTest method SetupListener.
public void SetupListener() {
final R5ConnectionListener additionalListener = this;
final SubscribeReconnectTest subscribeTest = this;
final R5Stream subscriber = this.subscribe;
final R5VideoView view = this.display;
subscribe.setListener(new R5ConnectionListener() {
@Override
public void onConnectionEvent(R5ConnectionEvent r5ConnectionEvent) {
final R5ConnectionListener me = this;
additionalListener.onConnectionEvent(r5ConnectionEvent);
if (r5ConnectionEvent == R5ConnectionEvent.CLOSE && !SubscribeReconnectTest.this.stopped) {
Handler h = new Handler(Looper.getMainLooper());
h.postDelayed(new Runnable() {
@Override
public void run() {
if (!stopped) {
subscribeTest.findStreams();
}
}
}, reconnectDelay);
} else if (r5ConnectionEvent == R5ConnectionEvent.NET_STATUS && r5ConnectionEvent.message.equals("NetStream.Play.UnpublishNotify")) {
Handler h = new Handler(Looper.getMainLooper());
h.postDelayed(new Runnable() {
@Override
public void run() {
subscriber.setListener(null);
subscriber.stop();
view.attachStream(null);
subscribeTest.delayReconnect(reconnectDelay);
}
}, reconnectDelay);
}
}
});
}
use of com.red5pro.streaming.view.R5VideoView in project streaming-android by red5pro.
the class SubscribeReconnectTest method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.subscribe_test, container, false);
// find the view and attach the stream
display = (R5VideoView) view.findViewById(R.id.videoView);
findStreams();
return view;
}
Aggregations