VideoModule.java
5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package com.sw.laryngoscope.camera;
import com.sw.laryngoscope.activity.fragment.HomeFragment;
import com.sw.laryngoscope.common.InitParam;
import com.sw.laryngoscope.utils.Logger;
public class VideoModule {
private HomeFragment fragment;
private VideoUI mUI;
private VideoManager mVideoManager;
private VideoCBModule mVideoCBModule;
private VideoCFModule mVideoCFModule;
private int mCameraType = InitParam.CAM_BACK;
public VideoModule() {
}
public void init(HomeFragment fragment) {
this.fragment = fragment;
mUI = new VideoUI(fragment, fragment.getRootView());
mVideoManager = new VideoManager(fragment.getActivity().getApplicationContext());
mVideoManager.startThread(fragment.getActivity().getApplicationContext());
mVideoCBModule = new VideoCBModule();
mVideoCBModule.init(fragment, mUI, mVideoManager);
mVideoCBModule.setmOnMediaListener(fragment);
mVideoCFModule = new VideoCFModule();
mVideoCFModule.init(fragment, mUI, mVideoManager);
mVideoCFModule.setmOnMediaListener(fragment);
}
public void startBackPreview() {
mVideoCBModule.startPreview();
}
public void startFrontPreview() {
mVideoCFModule.startPreview();
}
public synchronized void startBackVideoRec() {
mVideoCBModule.startVideoRecording();
}
public synchronized void startFrontVideoRec() {
mVideoCFModule.startVideoRecording();
}
public synchronized void stopBackVideoRec() {
Logger.d("========HomeFragment===1=========" + mVideoCBModule);
mVideoCBModule.stopVideoRecording();
}
public synchronized void stopFrontVideoRec() {
Logger.d("========HomeFragment===2=========" + mVideoCFModule);
mVideoCFModule.stopVideoRecording();
}
public synchronized boolean stopBackVideoRecDelay() {
Logger.d("========HomeFragment===1=========" + mVideoCBModule);
return mVideoCBModule.stopVideoRecordingDelay();
}
public synchronized boolean stopFrontVideoRecDelay() {
Logger.d("========HomeFragment===2=========" + mVideoCFModule);
return mVideoCFModule.stopVideoRecordingDelay();
}
public void destoryBackMediaRec() {
mVideoCBModule.destoryMediaRecoder();
}
public void destoryFrontMediaRec() {
mVideoCFModule.destoryMediaRecoder();
}
public void closeCamera() {
mVideoCBModule.closeCamera();
mVideoCFModule.closeCamera();
}
public void closeBackCamera() {
mVideoCBModule.closeCamera();
}
public synchronized void closeFrontCamera() {
mVideoCFModule.closeCamera();
}
public void closeCheckSpace() {
if (mVideoManager != null) {
mVideoManager.stopThread();
}
}
public synchronized boolean isBackRec() {
return mVideoCBModule.isRecording();
}
public synchronized boolean isFrontRec() {
return mVideoCFModule.isRecording();
}
public boolean isOpenBackCamera() {
return mVideoCBModule.isOpenCamera();
}
public boolean isOpenFrontCamera() {
return mVideoCFModule.isOpenCamera();
}
public VideoManager getmVideoManager() {
return mVideoManager;
}
public void takeBackPhoto() {
if ( isOpenBackCamera() ) {
mVideoCBModule.burstcapture();
}
}
public void takeFrontPhoto() {
if ( isOpenFrontCamera() ) {
mVideoCFModule.burstcapture();
}
}
//主显示的摄像头类型
public void setMainCameraType(int type) {
mCameraType = type;
}
//主显示的摄像头类型
public int getMainCameraType() {
return mCameraType;
}
public void setCbWhiteBalance(int i, boolean auto) {
mVideoCBModule.setWhiteBalance(i, auto);
}
public void setCfWhiteBalance(int i, boolean auto) {
mVideoCFModule.setWhiteBalance(i, auto);
}
public int getAwbParam() {
return mVideoCBModule.getAwbParam();
}
public void setZoom(int i) {
//mVideoCBModule.setZoom(i);
}
public int getZoom() {
return mVideoCBModule.getZoom();
}
public void setBackId(int id) {
BaseModule.FACING_BACK_ID = id;
}
public void setFrontId(int id) {
BaseModule.FACING_FRONT_ID = id;
}
public void setBackCamShow(int visibility) {
mVideoCBModule.setCameraShow(visibility);
}
public void setFrontCamShow(int visibility) {
mVideoCFModule.setCameraShow(visibility);
}
public void setDisplayOrientation() {
mVideoCBModule.setDisplayOrientation();
}
public int getSingleCamSize() {
int ret = 0;
if ( mVideoCBModule != null ) {
ret = CameraUtils.getCamSize(mVideoCBModule.previewSizeWidth, mVideoCBModule.previewSizeHeight);
}
return ret;
}
public void setBackCamZoom() {
mVideoCBModule.setZoom();
}
public void setFrontCamZoom() {
mVideoCFModule.setZoom();
}
/*public void takeIcePhoto(VideoCBModule.OnMediaSavedListener listener) {
if ( isOpenCamera() ) {
mVideoCBModule.burstIcecapture(listener);
}
}*/
}