File tree Expand file tree Collapse file tree
dConnectDevicePlugin/dConnectDeviceUVC/app/src/main
java/org/deviceconnect/android/deviceplugin/uvc/recorder Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .deviceconnect .android .deviceplugin .uvc .recorder ;
22
3+ import android .util .Log ;
4+
35import org .deviceconnect .android .libmedia .streaming .MediaEncoderException ;
46import org .deviceconnect .android .libmedia .streaming .audio .AudioEncoder ;
57import org .deviceconnect .android .libmedia .streaming .audio .AudioQuality ;
@@ -68,7 +70,11 @@ public void start(OnStartCallback callback) {
6870 setAudioQuality (audioEncoder .getAudioQuality ());
6971 }
7072
73+ MediaRecorder .Settings settings = getRecorder ().getSettings ();
74+
7175 mRtmpClient = new RtmpClient (getBroadcastURI ());
76+ mRtmpClient .setMaxRetryCount (settings .getRetryCount ());
77+ mRtmpClient .setRetryInterval (settings .getRetryInterval ());
7278 mRtmpClient .setVideoEncoder (videoEncoder );
7379 mRtmpClient .setAudioEncoder (audioEncoder );
7480 mRtmpClient .setOnEventListener (new RtmpClient .OnEventListener () {
@@ -99,6 +105,8 @@ public void onError(MediaEncoderException e) {
99105 if (mOnBroadcasterEventListener != null ) {
100106 mOnBroadcasterEventListener .onError (e );
101107 }
108+
109+ AbstractRTMPBroadcaster .this .stop ();
102110 }
103111
104112 @ Override
@@ -107,7 +115,6 @@ public void onConnected() {
107115
108116 @ Override
109117 public void onDisconnected () {
110- AbstractRTMPBroadcaster .this .stop ();
111118 }
112119
113120 @ Override
Original file line number Diff line number Diff line change @@ -68,7 +68,11 @@ public void start(OnStartCallback callback) {
6868 setAudioQuality (audioEncoder .getAudioQuality ());
6969 }
7070
71+ MediaRecorder .Settings settings = getRecorder ().getSettings ();
72+
7173 mSrtClient = new SRTClient (getBroadcastURI ());
74+ mSrtClient .setMaxRetryCount (settings .getRetryCount ());
75+ mSrtClient .setRetryInterval (settings .getRetryInterval ());
7276 mSrtClient .setVideoEncoder (videoEncoder );
7377 mSrtClient .setAudioEncoder (audioEncoder );
7478 mSrtClient .setOnEventListener (new SRTClient .OnEventListener () {
@@ -99,6 +103,7 @@ public void onError(MediaEncoderException e) {
99103 if (mOnBroadcasterEventListener != null ) {
100104 mOnBroadcasterEventListener .onError (e );
101105 }
106+ AbstractSRTBroadcaster .this .stop ();
102107 }
103108
104109 @ Override
@@ -107,7 +112,6 @@ public void onConnected() {
107112
108113 @ Override
109114 public void onDisconnected () {
110- AbstractSRTBroadcaster .this .stop ();
111115 }
112116
113117 @ Override
Original file line number Diff line number Diff line change @@ -1029,6 +1029,50 @@ public void setBroadcastURI(String broadcastURI) {
10291029 mPref .put ("broadcast_uri" , broadcastURI );
10301030 }
10311031
1032+ /**
1033+ * リトライ回数を取得します.
1034+ *
1035+ * @return リトライ回数
1036+ */
1037+ public int getRetryCount () {
1038+ return mPref .getInteger ("broadcast_retry_count" , 0 );
1039+ }
1040+
1041+ /**
1042+ * リトライ回数を設定します.
1043+ *
1044+ * @param count リトライ回数
1045+ */
1046+ public void setRetryCount (int count ) {
1047+ if (count < 0 ) {
1048+ mPref .remove ("broadcast_retry_count" );
1049+ } else {
1050+ mPref .put ("broadcast_retry_count" , count );
1051+ }
1052+ }
1053+
1054+ /**
1055+ * リトライのインターバルを取得します.
1056+ *
1057+ * @return リトライのインターバル
1058+ */
1059+ public int getRetryInterval () {
1060+ return mPref .getInteger ("broadcast_retry_interval" , 3000 );
1061+ }
1062+
1063+ /**
1064+ * リトライのインターバルを設定します.
1065+ *
1066+ * @param interval リトライのインターバル
1067+ */
1068+ public void setRetryInterval (int interval ) {
1069+ if (interval < 0 ) {
1070+ mPref .remove ("broadcast_retry_interval" );
1071+ } else {
1072+ mPref .put ("broadcast_retry_interval" , interval );
1073+ }
1074+ }
1075+
10321076 // ポート番号
10331077
10341078 /**
Original file line number Diff line number Diff line change 6464
6565 <!-- 配信設定画面 -->
6666 <string name =" uvc_recorder_settings_broadcast_uri" translatable =" false" >URL</string >
67+ <string name =" uvc_recorder_settings_broadcast_retry_count" translatable =" false" >リトライ回数</string >
68+ <string name =" uvc_recorder_settings_broadcast_retry_interval" translatable =" false" >リトライ間隔(ミリ秒)</string >
6769
6870 <!-- 通知用 -->
6971 <string name =" uvc_notification_preview" >PREVIEW</string >
Original file line number Diff line number Diff line change 1414 app : key =" broadcast_uri"
1515 app : useSimpleSummaryProvider =" true" />
1616
17+ <EditTextPreference
18+ android : defaultValue =" 0"
19+ android : singleLine =" true"
20+ android : title =" @string/uvc_recorder_settings_broadcast_retry_count"
21+ app : iconSpaceReserved =" false"
22+ app : key =" broadcast_retry_count"
23+ app : useSimpleSummaryProvider =" true" />
24+
25+ <EditTextPreference
26+ android : defaultValue =" 3000"
27+ android : singleLine =" true"
28+ android : title =" @string/uvc_recorder_settings_broadcast_retry_interval"
29+ app : iconSpaceReserved =" false"
30+ app : key =" broadcast_retry_interval"
31+ app : useSimpleSummaryProvider =" true" />
32+
1733 </PreferenceCategory >
1834
1935</PreferenceScreen >
You can’t perform that action at this time.
0 commit comments