4
4
import android .graphics .SurfaceTexture ;
5
5
import android .hardware .Camera ;
6
6
import android .util .AttributeSet ;
7
+ import android .util .Log ;
7
8
import android .view .Gravity ;
8
9
import android .view .TextureView ;
9
10
import android .widget .FrameLayout ;
14
15
15
16
import me .lake .librestreaming .client .RESClient ;
16
17
import me .lake .librestreaming .core .listener .RESConnectionListener ;
18
+ import me .lake .librestreaming .core .listener .RESScreenShotListener ;
17
19
import me .lake .librestreaming .core .listener .RESVideoChangeListener ;
18
20
import me .lake .librestreaming .encoder .MediaAudioEncoder ;
19
21
import me .lake .librestreaming .encoder .MediaEncoder ;
@@ -73,7 +75,7 @@ public void init(Context context , StreamAVOption avOption) {
73
75
resConfig = StreamConfig .build (context ,avOption );
74
76
boolean isSucceed = resClient .prepare (resConfig );
75
77
if (!isSucceed ) {
76
- // Log.w(TAG, "推流prepare方法返回false, 状态异常.");
78
+ Log .w (TAG , "推流prepare方法返回false, 状态异常." );
77
79
return ;
78
80
}
79
81
initPreviewTextureView ();
@@ -197,11 +199,47 @@ public void swapCamera(){
197
199
}
198
200
199
201
/**
200
- * 设置上下文
202
+ * 摄像头焦距 [0.0f,1.0f]
201
203
*/
202
- public void setContext ( Context context ){
204
+ public void setZoomByPercent ( float targetPercent ){
203
205
if (resClient != null ){
204
- resClient .setContext (context );
206
+ resClient .setZoomByPercent (targetPercent );
207
+ }
208
+ }
209
+
210
+ /**
211
+ *摄像头开关闪光灯
212
+ */
213
+ public void toggleFlashLight (){
214
+ if (resClient != null ){
215
+ resClient .toggleFlashLight ();
216
+ }
217
+ }
218
+
219
+ /**
220
+ * 推流过程中,重新设置帧率
221
+ */
222
+ public void reSetVideoFPS (int fps ){
223
+ if (resClient != null ){
224
+ resClient .reSetVideoFPS (fps );
225
+ }
226
+ }
227
+
228
+ /**
229
+ * 推流过程中,重新设置码率
230
+ */
231
+ public void reSetVideoBitrate (int bitrate ){
232
+ if (resClient != null ){
233
+ resClient .reSetVideoBitrate (bitrate );
234
+ }
235
+ }
236
+
237
+ /**
238
+ * 截图
239
+ */
240
+ public void takeScreenShot (RESScreenShotListener listener ){
241
+ if (resClient != null ){
242
+ resClient .takeScreenShot (listener );
205
243
}
206
244
}
207
245
@@ -223,12 +261,21 @@ public float getSendBufferFreePercent() {
223
261
}
224
262
225
263
/**
226
- * AVSpeed
264
+ * AVSpeed 推流速度 和网络相关
227
265
*/
228
266
public int getAVSpeed () {
229
267
return resClient .getAVSpeed ();
230
268
}
231
269
270
+ /**
271
+ * 设置上下文
272
+ */
273
+ public void setContext (Context context ){
274
+ if (resClient != null ){
275
+ resClient .setContext (context );
276
+ }
277
+ }
278
+
232
279
/**
233
280
* destroy
234
281
*/
@@ -245,36 +292,6 @@ public void destroy(){
245
292
resClient .destroy ();
246
293
}
247
294
}
248
- /**
249
- * 外部调用,2秒轮询
250
- */
251
- public void fpsVbitPlan () {
252
- if (null == resClient ){
253
- return ;
254
- }
255
-
256
- int target ;
257
- int curr = resClient .getVideoBitrate ();
258
-
259
- if (curr == quality_value_min ){
260
- resClient .reSetVideoFPS (16 );
261
- }else if (curr == quality_value_max ) {
262
- resClient .reSetVideoFPS (20 );
263
- }
264
- //Log.e("wangshuo","Bitrate= "+curr);
265
- //Log.e("wangshuo","FreePercent= "+resClient.getSendBufferFreePercent());
266
- if (resClient .getSendBufferFreePercent () <= 0.99f ) {//reduce bitrate
267
- if (resClient .getVideoBitrate () > quality_value_min ) {
268
- target = (curr / 5 * 4 ) <= quality_value_min ? quality_value_min :(curr / 5 * 4 );
269
- resClient .reSetVideoBitrate (target );
270
- }
271
- } else {//raise bitrate
272
- if (resClient .getVideoBitrate () < quality_value_max ) {
273
- target = (curr / 500 * 501 ) >= quality_value_max ? quality_value_max :(curr / 500 * 501 );
274
- resClient .reSetVideoBitrate (target );
275
- }
276
- }
277
- }
278
295
279
296
/**
280
297
* 添加推流状态监听
0 commit comments