正在显示
13 个修改的文件
包含
256 行增加
和
101 行删除
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | <ConfirmationsSetting value="0" id="Add" /> | 37 | <ConfirmationsSetting value="0" id="Add" /> |
38 | <ConfirmationsSetting value="0" id="Remove" /> | 38 | <ConfirmationsSetting value="0" id="Remove" /> |
39 | </component> | 39 | </component> |
40 | - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | 40 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
41 | <output url="file://$PROJECT_DIR$/build/classes" /> | 41 | <output url="file://$PROJECT_DIR$/build/classes" /> |
42 | </component> | 42 | </component> |
43 | <component name="ProjectType"> | 43 | <component name="ProjectType"> |
MyApplication/.idea/vcs.xml
已删除
100644 → 0
@@ -207,6 +207,9 @@ public class VideoPlayActivity extends AppCompatActivity { | @@ -207,6 +207,9 @@ public class VideoPlayActivity extends AppCompatActivity { | ||
207 | case "audio_stop": | 207 | case "audio_stop": |
208 | 208 | ||
209 | break; | 209 | break; |
210 | + default:{ | ||
211 | + XdyLogUtil.e("xuedianyunlog",response); | ||
212 | + } | ||
210 | } | 213 | } |
211 | } | 214 | } |
212 | }); | 215 | }); |
@@ -26,6 +26,7 @@ package com.mang.xdy.demo.activity; | @@ -26,6 +26,7 @@ package com.mang.xdy.demo.activity; | ||
26 | 26 | ||
27 | import com.eventhandle.SmartEventCallback; | 27 | import com.eventhandle.SmartEventCallback; |
28 | import com.google.gson.Gson; | 28 | import com.google.gson.Gson; |
29 | + import com.mang.xdy.common.Constants; | ||
29 | import com.mang.xdy.core.XdySdk; | 30 | import com.mang.xdy.core.XdySdk; |
30 | import com.mang.xdy.demo.R; | 31 | import com.mang.xdy.demo.R; |
31 | import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter; | 32 | import com.mang.xdy.demo.adapter.SimpleFragmentPagerAdapter; |
@@ -119,8 +120,9 @@ public class VideoPublisherActivity extends AppCompatActivity { | @@ -119,8 +120,9 @@ public class VideoPublisherActivity extends AppCompatActivity { | ||
119 | break; | 120 | break; |
120 | case 6: | 121 | case 6: |
121 | //推流video | 122 | //推流video |
122 | - publisherVideo((String) msg.obj); | 123 | +// publisherVideo((String) msg.obj); |
123 | // publisherVideoText(); | 124 | // publisherVideoText(); |
125 | +// publisherAudioText(); | ||
124 | break; | 126 | break; |
125 | case 7: | 127 | case 7: |
126 | //停止播放 | 128 | //停止播放 |
@@ -166,15 +168,15 @@ public class VideoPublisherActivity extends AppCompatActivity { | @@ -166,15 +168,15 @@ public class VideoPublisherActivity extends AppCompatActivity { | ||
166 | //只有加入课堂成功才可以点击推流的按钮 | 168 | //只有加入课堂成功才可以点击推流的按钮 |
167 | handler.sendEmptyMessage(8); | 169 | handler.sendEmptyMessage(8); |
168 | break; | 170 | break; |
169 | - case "live": | 171 | +// case "live": |
170 | // case "publishVideo": | 172 | // case "publishVideo": |
171 | // String urls= "rtmp://player.daniulive.com:1935/hls/stream";; | 173 | // String urls= "rtmp://player.daniulive.com:1935/hls/stream";; |
172 | //推流直播 | 174 | //推流直播 |
173 | - Message message1=Message.obtain(); | ||
174 | - message1.obj = response; | ||
175 | - message1.what = 6; | ||
176 | - handler.sendMessage(message1); | ||
177 | - break; | 175 | +// Message message1=Message.obtain(); |
176 | +// message1.obj = response; | ||
177 | +// message1.what = 6; | ||
178 | +// handler.sendMessage(message1); | ||
179 | +// break; | ||
178 | case "video_stop": | 180 | case "video_stop": |
179 | // handler.sendEmptyMessage(7); | 181 | // handler.sendEmptyMessage(7); |
180 | break; | 182 | break; |
@@ -296,10 +298,22 @@ public class VideoPublisherActivity extends AppCompatActivity { | @@ -296,10 +298,22 @@ public class VideoPublisherActivity extends AppCompatActivity { | ||
296 | String s = XdyStringUtils.stringToJson(tem, true); | 298 | String s = XdyStringUtils.stringToJson(tem, true); |
297 | XdySdk.setAsyncApi(ids_new, s); | 299 | XdySdk.setAsyncApi(ids_new, s); |
298 | } | 300 | } |
301 | + | ||
302 | + /** | ||
303 | + * 获取封装的推流地址 | ||
304 | + */ | ||
299 | public void publisherVideoText(){ | 305 | public void publisherVideoText(){ |
300 | - XdySdk.setAsyncApi("publishVideo", "", surfaceview_pubisherVideo, VideoPublisherActivity.this,""); | 306 | +// XdySdk.setAsyncApi("publishVideo", "", surfaceview_pubisherVideo, VideoPublisherActivity.this,""); |
301 | 307 | ||
302 | } | 308 | } |
309 | + | ||
310 | + /** | ||
311 | + * 测试Audio | ||
312 | + */ | ||
313 | + public void publisherAudioText(){ | ||
314 | + XdySdk.setAsyncApi(Constants.PUBLISH_AUDIO, "", surfaceview_pubisherVideo, VideoPublisherActivity.this,""); | ||
315 | + | ||
316 | + } | ||
303 | public void publisherVideo(String response) { | 317 | public void publisherVideo(String response) { |
304 | String url = XdyStringUtils.stringToJson(response); | 318 | String url = XdyStringUtils.stringToJson(response); |
305 | XdyLogUtil.e("调用任务了播url:", "" + url); | 319 | XdyLogUtil.e("调用任务了播url:", "" + url); |
@@ -364,7 +378,9 @@ public class VideoPublisherActivity extends AppCompatActivity { | @@ -364,7 +378,9 @@ public class VideoPublisherActivity extends AppCompatActivity { | ||
364 | handler.sendEmptyMessage(4); | 378 | handler.sendEmptyMessage(4); |
365 | break; | 379 | break; |
366 | case R.id.btn_videoPlay_pubsherVideo: | 380 | case R.id.btn_videoPlay_pubsherVideo: |
367 | - getPublish(); | 381 | +// getPublish(); |
382 | +// publisherVideoText(); | ||
383 | + publisherAudioText(); | ||
368 | ToastUtil.showToastshort("推送视频",VideoPublisherActivity.this); | 384 | ToastUtil.showToastshort("推送视频",VideoPublisherActivity.this); |
369 | btnVideoPlayPubsherVideo.setClickable(false); | 385 | btnVideoPlayPubsherVideo.setClickable(false); |
370 | break; | 386 | break; |
1 | +package com.mang.xdy.bean; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by abao on 2017/4/13. | ||
5 | + */ | ||
6 | + | ||
7 | +public class ErrorCodeEntity { | ||
8 | + | ||
9 | + /** | ||
10 | + * code : 898 | ||
11 | + * reson : | ||
12 | + */ | ||
13 | + | ||
14 | + private int code; | ||
15 | + private String reson; | ||
16 | + | ||
17 | + public int getCode() { | ||
18 | + return code; | ||
19 | + } | ||
20 | + | ||
21 | + public void setCode(int code) { | ||
22 | + this.code = code; | ||
23 | + } | ||
24 | + | ||
25 | + public String getReson() { | ||
26 | + return reson; | ||
27 | + } | ||
28 | + | ||
29 | + public void setReson(String reson) { | ||
30 | + this.reson = reson; | ||
31 | + } | ||
32 | +} |
1 | package com.mang.xdy.bean; | 1 | package com.mang.xdy.bean; |
2 | - | ||
3 | -// FIXME generate failure method set and get MediaId | ||
4 | -// FIXME generate failure field _$Replay151 | ||
5 | -// FIXME generate failure field _$RtmpUrl165 | ||
6 | -// FIXME generate failure field _$M3u8Url177 | ||
7 | -// FIXME generate failure field _$UserName168 | ||
8 | /** | 2 | /** |
9 | * Created by huang on 2017/4/9. | 3 | * Created by huang on 2017/4/9. |
10 | */ | 4 | */ |
@@ -22,10 +22,8 @@ import com.mang.xdy.utils.XdyLogUtil; | @@ -22,10 +22,8 @@ import com.mang.xdy.utils.XdyLogUtil; | ||
22 | */ | 22 | */ |
23 | public class XdyJsCore { | 23 | public class XdyJsCore { |
24 | private WebView mWebView; | 24 | private WebView mWebView; |
25 | + private static String TAG="xdyjscore"; | ||
25 | private static XdyJsCore mXdyCore; | 26 | private static XdyJsCore mXdyCore; |
26 | - /*同步调用方法返回值*/ | ||
27 | - private String revalue=""; | ||
28 | - | ||
29 | /** | 27 | /** |
30 | * 异步对外回调接口,所有回调都在此完成 | 28 | * 异步对外回调接口,所有回调都在此完成 |
31 | */ | 29 | */ |
@@ -107,12 +105,11 @@ public class XdyJsCore { | @@ -107,12 +105,11 @@ public class XdyJsCore { | ||
107 | * @param parameter | 105 | * @param parameter |
108 | */ | 106 | */ |
109 | protected void native2js(final String id, String parameter){ | 107 | protected void native2js(final String id, String parameter){ |
110 | - revalue=""; | ||
111 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | 108 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
112 | mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() { | 109 | mWebView.evaluateJavascript("javascript:_native2js('" + id + "','"+parameter+"')", new ValueCallback<String>() { |
113 | @Override | 110 | @Override |
114 | public void onReceiveValue(String value) { | 111 | public void onReceiveValue(String value) { |
115 | - XdyLogUtil.e("natice_js 同步", "" + value + ""); | 112 | + XdyLogUtil.e(TAG, value); |
116 | //TODO | 113 | //TODO |
117 | // if (!TextUtils.isEmpty(value)&&value.length()>10) { | 114 | // if (!TextUtils.isEmpty(value)&&value.length()>10) { |
118 | // if(mOnXdyAsyncMessageListener !=null){ | 115 | // if(mOnXdyAsyncMessageListener !=null){ |
@@ -15,6 +15,9 @@ import android.view.SurfaceView; | @@ -15,6 +15,9 @@ import android.view.SurfaceView; | ||
15 | 15 | ||
16 | import com.daniulive.smartpublisher.SmartPublisherJni; | 16 | import com.daniulive.smartpublisher.SmartPublisherJni; |
17 | import com.eventhandle.SmartEventCallback; | 17 | import com.eventhandle.SmartEventCallback; |
18 | +import com.mang.xdy.cache.ACache; | ||
19 | +import com.mang.xdy.common.Constants; | ||
20 | +import com.mang.xdy.utils.PlayerUtils; | ||
18 | import com.mang.xdy.utils.XdyLogUtil; | 21 | import com.mang.xdy.utils.XdyLogUtil; |
19 | import com.voiceengine.NTAudioRecord; | 22 | import com.voiceengine.NTAudioRecord; |
20 | 23 | ||
@@ -75,9 +78,9 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC | @@ -75,9 +78,9 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC | ||
75 | // if(isStart){ | 78 | // if(isStart){ |
76 | // return; | 79 | // return; |
77 | // } | 80 | // } |
78 | -// if (xdyPublisher == null) { | 81 | + if (xdyPublisher == null) { |
79 | xdyPublisher = new SmartPublisherJni(); | 82 | xdyPublisher = new SmartPublisherJni(); |
80 | -// } | 83 | + } |
81 | isStart=true; | 84 | isStart=true; |
82 | pubSurfaceViewHolder = mSurfaceView.getHolder(); | 85 | pubSurfaceViewHolder = mSurfaceView.getHolder(); |
83 | pubSurfaceViewHolder.addCallback(this); | 86 | pubSurfaceViewHolder.addCallback(this); |
@@ -139,15 +142,19 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC | @@ -139,15 +142,19 @@ public class XdyPublisherCore implements SurfaceHolder.Callback, Camera.PreviewC | ||
139 | // if(isStart){ | 142 | // if(isStart){ |
140 | // return; | 143 | // return; |
141 | // } | 144 | // } |
142 | -// if (xdyPublisher == null) { | 145 | + if (xdyPublisher == null) { |
143 | xdyPublisher = new SmartPublisherJni(); | 146 | xdyPublisher = new SmartPublisherJni(); |
144 | -// } | 147 | + } |
145 | 148 | ||
146 | isStart=true; | 149 | isStart=true; |
147 | Log.e(TAG, "surfaceCreated.."); | 150 | Log.e(TAG, "surfaceCreated.."); |
148 | 151 | ||
149 | int i = xdyPublisher.SmartPublisherInit(mActivity, audio_opt,video_opt, videoWidth, videoHight); | 152 | int i = xdyPublisher.SmartPublisherInit(mActivity, audio_opt,video_opt, videoWidth, videoHight); |
150 | - Log.e(TAG, "SmartPublisherInit:初始化返回值是0成功: " + i); | 153 | + if(i!=0){ |
154 | + Log.e(TAG, "SmartPublisherInit:初始化返回值是0成功: " + i); | ||
155 | + return; | ||
156 | + } | ||
157 | + | ||
151 | xdyPublisher.SetSmartPublisherEventCallback(smartEventCallback); | 158 | xdyPublisher.SetSmartPublisherEventCallback(smartEventCallback); |
152 | if (xdyPublisher.SmartPublisherSetURL(rtmpUrl) != 0) { | 159 | if (xdyPublisher.SmartPublisherSetURL(rtmpUrl) != 0) { |
153 | Log.e(TAG, "Failed to set publish stream URL.."); | 160 | Log.e(TAG, "Failed to set publish stream URL.."); |
@@ -2,7 +2,6 @@ package com.mang.xdy.core; | @@ -2,7 +2,6 @@ package com.mang.xdy.core; | ||
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Context; | 4 | import android.content.Context; |
5 | -import android.nfc.Tag; | ||
6 | import android.os.Handler; | 5 | import android.os.Handler; |
7 | import android.os.Message; | 6 | import android.os.Message; |
8 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
@@ -10,25 +9,26 @@ import android.util.Log; | @@ -10,25 +9,26 @@ import android.util.Log; | ||
10 | import android.view.SurfaceView; | 9 | import android.view.SurfaceView; |
11 | 10 | ||
12 | import com.eventhandle.SmartEventCallback; | 11 | import com.eventhandle.SmartEventCallback; |
13 | -import com.google.gson.JsonNull; | ||
14 | import com.mang.xdy.bean.AudioPlayBean; | 12 | import com.mang.xdy.bean.AudioPlayBean; |
15 | import com.mang.xdy.bean.GetPublishPathReceiveBean; | 13 | import com.mang.xdy.bean.GetPublishPathReceiveBean; |
16 | import com.mang.xdy.bean.PublisherVideoReturnBean; | 14 | import com.mang.xdy.bean.PublisherVideoReturnBean; |
17 | import com.mang.xdy.bean.VideoPlayBean; | 15 | import com.mang.xdy.bean.VideoPlayBean; |
18 | import com.mang.xdy.cache.ACache; | 16 | import com.mang.xdy.cache.ACache; |
19 | import com.mang.xdy.common.Constants; | 17 | import com.mang.xdy.common.Constants; |
18 | +import com.mang.xdy.message.MsgManage; | ||
20 | import com.mang.xdy.utils.JsonUtil; | 19 | import com.mang.xdy.utils.JsonUtil; |
21 | import com.mang.xdy.utils.PlayerUtils; | 20 | import com.mang.xdy.utils.PlayerUtils; |
22 | import com.mang.xdy.utils.XdyLogUtil; | 21 | import com.mang.xdy.utils.XdyLogUtil; |
23 | import com.mang.xdy.utils.XdyStringUtils; | 22 | import com.mang.xdy.utils.XdyStringUtils; |
24 | 23 | ||
25 | -import java.io.FileNotFoundException; | ||
26 | - | ||
27 | -import static com.mang.xdy.utils.PlayerUtils.getPublishPath; | 24 | +import static com.mang.xdy.utils.PlayerUtils.getPublishPathAudio; |
25 | +import static com.mang.xdy.utils.PlayerUtils.getPublishPathVideo; | ||
28 | 26 | ||
29 | /** | 27 | /** |
30 | * 对外调用的接口 | 28 | * 对外调用的接口 |
31 | * Created by abao on 2017/3/31. | 29 | * Created by abao on 2017/3/31. |
30 | + * 受原先的文档设计的规则,所有方法的都是静态的方法,影响性能 | ||
31 | + * 考虑跟换文档,提升性能 | ||
32 | */ | 32 | */ |
33 | public class XdySdk { | 33 | public class XdySdk { |
34 | /** | 34 | /** |
@@ -39,8 +39,11 @@ public class XdySdk { | @@ -39,8 +39,11 @@ public class XdySdk { | ||
39 | private static Context mContext; | 39 | private static Context mContext; |
40 | private static XdyPlayerCore mXdyPlayerCore; | 40 | private static XdyPlayerCore mXdyPlayerCore; |
41 | private static XdyPublisherCore mXdyPublisherCore; | 41 | private static XdyPublisherCore mXdyPublisherCore; |
42 | + /*消息管理*/ | ||
43 | + private static MsgManage mMsgManage; | ||
42 | 44 | ||
43 | public static String TAG="xdysdk"; | 45 | public static String TAG="xdysdk"; |
46 | + /*缓存管理*/ | ||
44 | private static ACache aCache; | 47 | private static ACache aCache; |
45 | //TODO 拿不到同步的数据先保留信息(必须释放,否者内存泄漏) | 48 | //TODO 拿不到同步的数据先保留信息(必须释放,否者内存泄漏) |
46 | private static SurfaceView mSurfaceView; | 49 | private static SurfaceView mSurfaceView; |
@@ -84,12 +87,21 @@ public class XdySdk { | @@ -84,12 +87,21 @@ public class XdySdk { | ||
84 | } | 87 | } |
85 | mContext=context; | 88 | mContext=context; |
86 | mXdyJsCore = XdyJsCore.getInstance(context); | 89 | mXdyJsCore = XdyJsCore.getInstance(context); |
90 | + mMsgManage=MsgManage.getErrorMsgInstance(); | ||
91 | + mMsgManage.setXdyMsgManageListener(new MsgManage.OnXdyMsgManageListener() { | ||
92 | + @Override | ||
93 | + public void onXdyMsgResponse(String type, String response) { | ||
94 | + //处理数据异常,传递给最外层 | ||
95 | + handleListener(type,response); | ||
96 | + } | ||
97 | + }); | ||
87 | mXdyJsCore.setXdyAsyncMessageListener(new XdyJsCore.OnXdyAsyncMessageListener() { | 98 | mXdyJsCore.setXdyAsyncMessageListener(new XdyJsCore.OnXdyAsyncMessageListener() { |
88 | @Override | 99 | @Override |
89 | public void getSdyAsyncMessageListener(String id, String parameter) { | 100 | public void getSdyAsyncMessageListener(String id, String parameter) { |
90 | handleData(id,parameter); | 101 | handleData(id,parameter); |
91 | } | 102 | } |
92 | }); | 103 | }); |
104 | + aCache=ACache.get(mContext); | ||
93 | } | 105 | } |
94 | 106 | ||
95 | /** | 107 | /** |
@@ -132,40 +144,6 @@ public class XdySdk { | @@ -132,40 +144,6 @@ public class XdySdk { | ||
132 | // break; | 144 | // break; |
133 | } | 145 | } |
134 | } | 146 | } |
135 | - /** | ||
136 | - * 重载推流 | ||
137 | - * @param type | ||
138 | - * @param rtmpUrl | ||
139 | - * @param surfaceView | ||
140 | - * @param activity | ||
141 | - * @deprecated | ||
142 | - */ | ||
143 | - public static void setAsyncApi(String type, String rtmpUrl, SurfaceView surfaceView, Activity activity) { | ||
144 | - switch (type) { | ||
145 | - case "playVideo": | ||
146 | - //播放音频 | ||
147 | - case "playAudio": | ||
148 | - //播放视频 | ||
149 | -// mXdyPlayerCore = new XdyPlayerCore(rtmpUrl,surfaceView, activity); | ||
150 | -// mXdyPlayerCore= XdyPlayerCore.getXdyPlayerCore(rtmpUrl,surfaceView, activity); | ||
151 | -// mXdyPlayerCore.playVideo(rtmpUrl, surfaceView,su); | ||
152 | - break; | ||
153 | -// case "publishVideo": | ||
154 | -// //打开推流视频 | ||
155 | -// if(mXdyPublisherCore==null) | ||
156 | -// mXdyPublisherCore=new XdyPublisherCore(1,1,rtmpUrl,surfaceView,activity); | ||
157 | -// mXdyPublisherCore.publisher(rtmpUrl,surfaceView); | ||
158 | -// break; | ||
159 | -// | ||
160 | -// case "publishAudio": | ||
161 | -// //只推送音频 | ||
162 | -// if(mXdyPublisherCore==null) | ||
163 | -// mXdyPublisherCore=new XdyPublisherCore(1,0,rtmpUrl,surfaceView,activity); | ||
164 | -// mXdyPublisherCore.publisherAudio(rtmpUrl); | ||
165 | -// break; | ||
166 | - | ||
167 | - } | ||
168 | - } | ||
169 | 147 | ||
170 | /** | 148 | /** |
171 | * 重载推流 | 149 | * 重载推流 |
@@ -265,13 +243,15 @@ public class XdySdk { | @@ -265,13 +243,15 @@ public class XdySdk { | ||
265 | * 3,推流成功告知后台,和用户 | 243 | * 3,推流成功告知后台,和用户 |
266 | * | 244 | * |
267 | */ | 245 | */ |
268 | - getPublishPath(); | 246 | + getPublishPathVideo(); |
269 | mSurfaceView=surfaceView; | 247 | mSurfaceView=surfaceView; |
270 | mActivity=activity; | 248 | mActivity=activity; |
271 | break; | 249 | break; |
272 | case Constants.PUBLISH_AUDIO: | 250 | case Constants.PUBLISH_AUDIO: |
273 | //只推送音频 | 251 | //只推送音频 |
274 | - getPublishPath(); | 252 | + getPublishPathAudio(); |
253 | + mSurfaceView=surfaceView; | ||
254 | + mActivity=activity; | ||
275 | // if(mXdyPublisherCore==null) | 255 | // if(mXdyPublisherCore==null) |
276 | // mXdyPublisherCore=new XdyPublisherCore(1,0,rtmpUrl,surfaceView,activity); | 256 | // mXdyPublisherCore=new XdyPublisherCore(1,0,rtmpUrl,surfaceView,activity); |
277 | // mXdyPublisherCore.publisherAudio(rtmpUrl,smartEventCallback); | 257 | // mXdyPublisherCore.publisherAudio(rtmpUrl,smartEventCallback); |
@@ -343,26 +323,35 @@ public class XdySdk { | @@ -343,26 +323,35 @@ public class XdySdk { | ||
343 | case Constants.GET_VIDEO_PUBLISH_PATH: | 323 | case Constants.GET_VIDEO_PUBLISH_PATH: |
344 | //推流地址的返回值拿到正确的推流地址直接开始推流 | 324 | //推流地址的返回值拿到正确的推流地址直接开始推流 |
345 | //打开推流视频 | 325 | //打开推流视频 |
346 | - GetPublishPathReceiveBean getPublishPathReceiveBean=JsonUtil.parseJsonToBean(response,GetPublishPathReceiveBean.class); | ||
347 | - if(getPublishPathReceiveBean!=null&&getPublishPathReceiveBean.getCode()==0){ | 326 | + String publishPath=XdyStringUtils.stringToJson(response); |
327 | + GetPublishPathReceiveBean getPublishPathReceiveBean=JsonUtil.parseJsonToBean(publishPath,GetPublishPathReceiveBean.class); | ||
328 | + if(getPublishPathReceiveBean!=null) { | ||
348 | //可以推流了 | 329 | //可以推流了 |
349 | - //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 | ||
350 | - String video_url=getPublishPathReceiveBean.getPublishUrl(); | ||
351 | - aCache.put(Constants.GET_VIDEO_PUBLISH_PATH,video_url); | ||
352 | - //判断 | ||
353 | - if (mSurfaceView==null){ | ||
354 | - //todo 输出提示 | ||
355 | - return; | 330 | + if (getPublishPathReceiveBean.getCode() == 0) { |
331 | + //TODO 成功存储数据 文档上有mediaId ,实际获取没有,下个版本会加上,现在暂时用getvideopublishpath 做关键字 | ||
332 | + String video_url = getPublishPathReceiveBean.getPublishUrl(); | ||
333 | + aCache.put(Constants.GET_VIDEO_PUBLISH_PATH, video_url); | ||
334 | + //判断 | ||
335 | + if (mSurfaceView == null) { | ||
336 | + //todo 输出提示 | ||
337 | + return; | ||
338 | + } | ||
339 | + if (mActivity == null) { | ||
340 | + //TODo 给出提示 | ||
341 | + return; | ||
342 | + } | ||
343 | + if (mXdyPublisherCore == null) | ||
344 | + mXdyPublisherCore = new XdyPublisherCore(1, 1, video_url, mSurfaceView, mActivity); | ||
345 | + mXdyPublisherCore.publisher(video_url, new EventHande()); | ||
346 | +// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | ||
347 | + //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) | ||
348 | + PlayerUtils.setPublishSendSuccessVideo(video_url); | ||
349 | + }else{ | ||
350 | + mMsgManage.getPublishVideoPathError(); | ||
356 | } | 351 | } |
357 | - if(mActivity==null){ | ||
358 | - //TODo 给出提示 | ||
359 | - return; | ||
360 | - } | ||
361 | - if(mXdyPublisherCore==null) | ||
362 | - mXdyPublisherCore=new XdyPublisherCore(1,1,video_url,mSurfaceView,mActivity); | ||
363 | - mXdyPublisherCore.publisher(video_url,new EventHande()); | ||
364 | }else{ | 352 | }else{ |
365 | //给出提示 | 353 | //给出提示 |
354 | + mMsgManage.getPublishVideoPathError(); | ||
366 | } | 355 | } |
367 | // mXdyPublisherCore=new XdyPublisherCore(1,1,rtmpUrl,surfaceView,activity); | 356 | // mXdyPublisherCore=new XdyPublisherCore(1,1,rtmpUrl,surfaceView,activity); |
368 | // mXdyPublisherCore.publisher(rtmpUrl,smartEventCallback); | 357 | // mXdyPublisherCore.publisher(rtmpUrl,smartEventCallback); |
@@ -370,7 +359,8 @@ public class XdySdk { | @@ -370,7 +359,8 @@ public class XdySdk { | ||
370 | case Constants.GET_AUDIO_PUBLISH_PATH: | 359 | case Constants.GET_AUDIO_PUBLISH_PATH: |
371 | //推流地址的返回值拿到正确的推流地址直接开始推流 | 360 | //推流地址的返回值拿到正确的推流地址直接开始推流 |
372 | //打开推流视频 | 361 | //打开推流视频 |
373 | - GetPublishPathReceiveBean getPublishPathReceiveBean_Audio=JsonUtil.parseJsonToBean(response,GetPublishPathReceiveBean.class); | 362 | + String audio_path=XdyStringUtils.stringToJson(response); |
363 | + GetPublishPathReceiveBean getPublishPathReceiveBean_Audio=JsonUtil.parseJsonToBean(audio_path,GetPublishPathReceiveBean.class); | ||
374 | if(getPublishPathReceiveBean_Audio!=null&&getPublishPathReceiveBean_Audio.getCode()==0){ | 364 | if(getPublishPathReceiveBean_Audio!=null&&getPublishPathReceiveBean_Audio.getCode()==0){ |
375 | //可以推流了 | 365 | //可以推流了 |
376 | String audio_url=getPublishPathReceiveBean_Audio.getPublishUrl(); | 366 | String audio_url=getPublishPathReceiveBean_Audio.getPublishUrl(); |
@@ -386,27 +376,42 @@ public class XdySdk { | @@ -386,27 +376,42 @@ public class XdySdk { | ||
386 | return; | 376 | return; |
387 | } | 377 | } |
388 | if(mXdyPublisherCore==null) | 378 | if(mXdyPublisherCore==null) |
389 | - mXdyPublisherCore=new XdyPublisherCore(1,1,audio_url,mSurfaceView,mActivity); | ||
390 | - mXdyPublisherCore.publisher(audio_url,new EventHande()); | 379 | + mXdyPublisherCore=new XdyPublisherCore(1,0,audio_url,mSurfaceView,mActivity); |
380 | + mXdyPublisherCore.publisherAudio(audio_url,new EventHande()); | ||
381 | + //// TODO: 2017/4/13 大牛连接成功回调没有监听到 暂时在这告知后台,(后续加上网路判断,摄像头判断) | ||
382 | + PlayerUtils.setPublishSendSuccessAudio(audio_url); | ||
391 | }else{ | 383 | }else{ |
392 | //给出提示 | 384 | //给出提示 |
385 | + mMsgManage.getPublishVideoPathError(); | ||
393 | } | 386 | } |
394 | // mXdyPublisherCore=new XdyPublisherCore(1,1,rtmpUrl,surfaceView,activity); | 387 | // mXdyPublisherCore=new XdyPublisherCore(1,1,rtmpUrl,surfaceView,activity); |
395 | // mXdyPublisherCore.publisher(rtmpUrl,smartEventCallback); | 388 | // mXdyPublisherCore.publisher(rtmpUrl,smartEventCallback); |
396 | break; | 389 | break; |
397 | case Constants.PUBLISH_AUDIO: | 390 | case Constants.PUBLISH_AUDIO: |
398 | //只推送音频 | 391 | //只推送音频 |
399 | -// if(mXdyPublisherCore==null) | ||
400 | -// mXdyPublisherCore=new XdyPublisherCore(1,0,rtmpUrl,surfaceView,activity); | ||
401 | -// mXdyPublisherCore.publisherAudio(rtmpUrl,smartEventCallback); | 392 | + //接收后台是否接收到推流URl的地址 |
393 | + String publishReplay_Audio=response; | ||
394 | + XdyLogUtil.e(TAG,"后台成功接收到,返回值"+XdyStringUtils.stringToJson(publishReplay_Audio)); | ||
395 | + PublisherVideoReturnBean publisherVideoReturnBean_audio=JsonUtil.parseJsonToBean(XdyStringUtils.stringToJson(publishReplay_Audio),PublisherVideoReturnBean.class); | ||
396 | + if(publisherVideoReturnBean_audio!=null&&publisherVideoReturnBean_audio.getCode()==0){ | ||
397 | + XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); | ||
398 | + //TODO | ||
399 | + | ||
400 | + handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
401 | + }else{ | ||
402 | + //TODO | ||
403 | + handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | ||
404 | + } | ||
402 | break; | 405 | break; |
403 | case Constants.PUBLISH_VIDEO: | 406 | case Constants.PUBLISH_VIDEO: |
404 | //接收发送推流地址给后台返回的信息 | 407 | //接收发送推流地址给后台返回的信息 |
405 | String publishReplay=response; | 408 | String publishReplay=response; |
406 | - PublisherVideoReturnBean publisherVideoReturnBean=JsonUtil.parseJsonToBean(publishReplay,PublisherVideoReturnBean.class); | 409 | + XdyLogUtil.e(TAG,"后台成功接收到,返回值"+XdyStringUtils.stringToJson(publishReplay)); |
410 | + PublisherVideoReturnBean publisherVideoReturnBean=JsonUtil.parseJsonToBean(XdyStringUtils.stringToJson(publishReplay),PublisherVideoReturnBean.class); | ||
407 | if(publisherVideoReturnBean!=null&&publisherVideoReturnBean.getCode()==0){ | 411 | if(publisherVideoReturnBean!=null&&publisherVideoReturnBean.getCode()==0){ |
408 | XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); | 412 | XdyLogUtil.e(TAG,"后台成功接收到,推流的地址"); |
409 | //TODO | 413 | //TODO |
414 | + | ||
410 | handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); | 415 | handleListener(Constants.PUBLISH_RERUEN_SUCCESS,""); |
411 | }else{ | 416 | }else{ |
412 | //TODO | 417 | //TODO |
@@ -468,6 +473,12 @@ public class XdySdk { | @@ -468,6 +473,12 @@ public class XdySdk { | ||
468 | mXdyPublisherCore.onStopPublisher(); | 473 | mXdyPublisherCore.onStopPublisher(); |
469 | mXdyPublisherCore=null; | 474 | mXdyPublisherCore=null; |
470 | } | 475 | } |
476 | + if(mSurfaceView!=null){ | ||
477 | + mSurfaceView=null; | ||
478 | + } | ||
479 | + if(mActivity!=null){ | ||
480 | + mActivity=null; | ||
481 | + } | ||
471 | } | 482 | } |
472 | 483 | ||
473 | static class EventHande implements SmartEventCallback { | 484 | static class EventHande implements SmartEventCallback { |
@@ -476,6 +487,7 @@ public class XdySdk { | @@ -476,6 +487,7 @@ public class XdySdk { | ||
476 | switch (code) { | 487 | switch (code) { |
477 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: | 488 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_STARTED: |
478 | Log.i(TAG, "开始。。"); | 489 | Log.i(TAG, "开始。。"); |
490 | + mMsgManage.getPublishVideoPathError(); | ||
479 | break; | 491 | break; |
480 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: | 492 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTING: |
481 | Log.i(TAG, "连接中。。"); | 493 | Log.i(TAG, "连接中。。"); |
@@ -486,7 +498,7 @@ public class XdySdk { | @@ -486,7 +498,7 @@ public class XdySdk { | ||
486 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: | 498 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_CONNECTED: |
487 | Log.i(TAG, "连接成功。。"); | 499 | Log.i(TAG, "连接成功。。"); |
488 | //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 | 500 | //TODO //如果连接成功发送连接成功信息,判断的方式有待考虑 |
489 | - PlayerUtils.setPublishSendSuccess(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); | 501 | +// PlayerUtils.setPublishSendSuccessVideo(aCache.getAsString(Constants.GET_VIDEO_PUBLISH_PATH)); |
490 | break; | 502 | break; |
491 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: | 503 | case EVENTID.EVENT_DANIULIVE_ERC_PLAYER_DISCONNECTED: |
492 | Log.i(TAG, "连接断开。。"); | 504 | Log.i(TAG, "连接断开。。"); |
1 | +package com.mang.xdy.message; | ||
2 | + | ||
3 | +import com.google.gson.Gson; | ||
4 | +import com.mang.xdy.bean.ErrorCodeEntity; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by abao on 2017/4/13. | ||
8 | + * 对外返回错误信息 | ||
9 | + * | ||
10 | + */ | ||
11 | + | ||
12 | +public class MsgManage { | ||
13 | + private MsgManage(){} | ||
14 | + private static class ErrorInner{ | ||
15 | + private final static MsgManage ERROR_MANAGE =new MsgManage(); | ||
16 | + } | ||
17 | + public static MsgManage getErrorMsgInstance(){ | ||
18 | + return ErrorInner.ERROR_MANAGE; | ||
19 | + } | ||
20 | + | ||
21 | + public void sendErrroMsg(String ss){ | ||
22 | + | ||
23 | + } | ||
24 | + public interface OnXdyMsgManageListener{ | ||
25 | + /** | ||
26 | + * 返回的类型,和信息 | ||
27 | + * @param type | ||
28 | + * @param response | ||
29 | + */ | ||
30 | + void onXdyMsgResponse(String type,String response); | ||
31 | + } | ||
32 | + private OnXdyMsgManageListener mOnXdyMsgManageListener; | ||
33 | + public void setXdyMsgManageListener(OnXdyMsgManageListener onXdyMsgManageListener){ | ||
34 | + mOnXdyMsgManageListener=onXdyMsgManageListener; | ||
35 | + } | ||
36 | + /** | ||
37 | + * 生成错误信息字符json字符串 | ||
38 | + * @param errorCode | ||
39 | + * @param errorMsg | ||
40 | + * @return | ||
41 | + */ | ||
42 | + public String parseErroJson(int errorCode,String errorMsg){ | ||
43 | + ErrorCodeEntity errorCodeEntity=new ErrorCodeEntity(); | ||
44 | + errorCodeEntity.setCode(errorCode); | ||
45 | + errorCodeEntity.setReson(errorMsg); | ||
46 | + String response=new Gson().toJson(errorCodeEntity); | ||
47 | + return response; | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * 对外发布消息 | ||
52 | + * @param type | ||
53 | + * @param response | ||
54 | + */ | ||
55 | + public void setMsg(String type,String response){ | ||
56 | + if(mOnXdyMsgManageListener!=null){ | ||
57 | + mOnXdyMsgManageListener.onXdyMsgResponse(type,response); | ||
58 | + } | ||
59 | + } | ||
60 | + /** | ||
61 | + * 获取视频推流地址失败 | ||
62 | + */ | ||
63 | + public void getPublishVideoPathError(){ | ||
64 | + String mess= parseErroJson(1,"获取视频推流地址错误"); | ||
65 | + setMsg("xdysdk",mess); | ||
66 | + } | ||
67 | + | ||
68 | +} |
@@ -16,23 +16,46 @@ public class PlayerUtils { | @@ -16,23 +16,46 @@ public class PlayerUtils { | ||
16 | *获取推流地址 | 16 | *获取推流地址 |
17 | * 这个地址的接收目前在同步的接口,后期做异步处理 | 17 | * 这个地址的接收目前在同步的接口,后期做异步处理 |
18 | * */ | 18 | * */ |
19 | - public static void getPublishPath() { | 19 | + public static void getPublishPathVideo() { |
20 | String tem = "{ \"type\": \"live\"}"; | 20 | String tem = "{ \"type\": \"live\"}"; |
21 | String s = XdyStringUtils.stringToJson(tem, true); | 21 | String s = XdyStringUtils.stringToJson(tem, true); |
22 | XdySdk.setAsyncApi(Constants.GET_VIDEO_PUBLISH_PATH, s); | 22 | XdySdk.setAsyncApi(Constants.GET_VIDEO_PUBLISH_PATH, s); |
23 | } | 23 | } |
24 | 24 | ||
25 | /** | 25 | /** |
26 | - * 向后台发送推流成功的信息 | 26 | + * 获取音频推流地址 |
27 | + */ | ||
28 | + public static void getPublishPathAudio() { | ||
29 | + String tem = "{ \"type\": \"live\"}"; | ||
30 | + String s = XdyStringUtils.stringToJson(tem, true); | ||
31 | + XdySdk.setAsyncApi(Constants.GET_AUDIO_PUBLISH_PATH, s); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * 向后台发送推流(Video)成功的信息 | ||
27 | * @param url | 36 | * @param url |
28 | */ | 37 | */ |
29 | - public static void setPublishSendSuccess(String url) { | 38 | + public static void setPublishSendSuccessVideo(String url) { |
30 | PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); | 39 | PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); |
31 | if (!TextUtils.isEmpty(url)) { | 40 | if (!TextUtils.isEmpty(url)) { |
32 | publisherEntity.setPublishUrl(url); | 41 | publisherEntity.setPublishUrl(url); |
33 | - String pamp = new Gson().toJson(url); | 42 | + String pamp = new Gson().toJson(publisherEntity); |
34 | XdyLogUtil.e("推流成功", "" + pamp); | 43 | XdyLogUtil.e("推流成功", "" + pamp); |
35 | XdySdk.setAsyncApi(Constants.PUBLISH_VIDEO, pamp); | 44 | XdySdk.setAsyncApi(Constants.PUBLISH_VIDEO, pamp); |
36 | } | 45 | } |
37 | } | 46 | } |
47 | + | ||
48 | + /** | ||
49 | + * 向后台发送推流数据(Auido)成功信息 | ||
50 | + * @param url | ||
51 | + */ | ||
52 | + public static void setPublishSendSuccessAudio(String url) { | ||
53 | + PublisherSuccessEntity publisherEntity = new PublisherSuccessEntity(); | ||
54 | + if (!TextUtils.isEmpty(url)) { | ||
55 | + publisherEntity.setPublishUrl(url); | ||
56 | + String pamp = new Gson().toJson(publisherEntity); | ||
57 | + XdyLogUtil.e("推流成功", "" + pamp); | ||
58 | + XdySdk.setAsyncApi(Constants.PUBLISH_AUDIO, pamp); | ||
59 | + } | ||
60 | + } | ||
38 | } | 61 | } |
-
请 注册 或 登录 后发表评论