Small Android application for video and audio communication with WebRTC with a WebView.
The repository at Github:
Small Android application for video and audio communication with WebRTC with a WebView.
The repository at Github:
ffmpeg -y -i movie.dav movie.mp4
SO_REUSEADDR Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. For PF_INET sockets this means that a socket may bind, except when there is an active listening socket bound to the address. When the listening socket is bound to INADDR_ANY with a specific port then it is not possible to bind to this port for any local address."
1: public void accepting(String aHostLocal, int aPortLocal) {
2: System.out.println("accepting");
3: ServerSocket serverSocket = null;
4: OutputStream outputStream = null;
5: BufferedReader bufferedReader = null;
6: try {
7: serverSocket = new ServerSocket();
8: serverSocket.setReuseAddress(true);
9:
10: System.out.println("accepting, bind to=" + aHostLocal);
11: InetSocketAddress socketAddress = new InetSocketAddress(aHostLocal, aPortLocal);
12: serverSocket.bind(socketAddress);
13:
14: System.out.println("accepting, accept");
15: Socket socket = serverSocket.accept();
16:
17: bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
18: int character = bufferedReader.read();
19: System.out.println("accepting, read character=" + character);
20: outputStream = socket.getOutputStream();
21: outputStream.write(character);
22: outputStream.flush();
23: } catch (IOException e) {
24: e.printStackTrace();
25: } finally {
26: if(bufferedReader != null) {
27: try {
28: bufferedReader.close();
29: } catch (IOException e) {
30: e.printStackTrace();
31: }
32: }
33: if(outputStream != null) {
34: try {
35: outputStream.close();
36: } catch (IOException e) {
37: e.printStackTrace();
38: }
39: }
40: if(serverSocket != null) {
41: try {
42: serverSocket.close();
43: } catch (IOException e) {
44: e.printStackTrace();
45: }
46: }
47: }
48: System.out.println("accepting, end");
49: }
50:
51: public void connecting(int aPortLocal, String aHostRemote, int aPortRemote) {
52: System.out.println("connecting");
53: Socket socket = null;
54: OutputStream outputStream = null;
55: BufferedReader bufferedReader = null;
56: try {
57: socket = new Socket();
58: socket.setReuseAddress(true);
59:
60: if(aPortLocal > 0) {
61: InetSocketAddress inetSocketAddress = new InetSocketAddress(aPortLocal);
62: System.out.println("connecting, bind to=" + inetSocketAddress);
63: socket.bind(inetSocketAddress);
64: }
65:
66: System.out.println("connecting, mHostRemote=" + aHostRemote);
67: InetSocketAddress socketAddress = new InetSocketAddress(aHostRemote, aPortRemote);
68: System.out.println("connecting, connect");
69: socket.connect(socketAddress, 30000);
70:
71: System.out.println("connecting, sending 10");
72: outputStream = socket.getOutputStream();
73: outputStream.write(10);
74: bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
75: int character = bufferedReader.read();
76: System.out.println("connecting received character=" + character);
77: outputStream.flush();
78: } catch (IOException e) {
79: e.printStackTrace();
80: } finally {
81: if(bufferedReader != null) {
82: try {
83: bufferedReader.close();
84: } catch (IOException e) {
85: e.printStackTrace();
86: }
87: }
88: if(outputStream != null) {
89: try {
90: outputStream.close();
91: } catch (IOException e) {
92: e.printStackTrace();
93: }
94: }
95: if(socket != null) {
96: try {
97: socket.close();
98: } catch (IOException e) {
99: e.printStackTrace();
100: }
101: }
102: }
103: System.out.println("connecting, end");
104: }