我是服务器端开发的新手。我想在一个应用程序上工作,我需要通过我的应用程序从我的 Android 设备在 Helix 服务器上录制视频。我已经在 Windows Server PC 上安装了 Helix Server。
在 Android 应用程序中,我试图在 Helix 服务器上上传录制的视频。我已经实现了在 SD 卡上录制视频的应用程序,但我想直接在 Helix Server 上录制并保存该视频。我已经实现了我的Android应用程序如下:
public class NewRecordingVideo extends Activity implements SurfaceHolder.Callback {
private MediaRecorder recorder;
boolean flag = false;
boolean startedRecording = false;
boolean stoppedRecording = false;
SurfaceHolder mHolder;
SurfaceView videoSView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.activity_main);
recorder = new MediaRecorder();
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
videoSView = ((SurfaceView)findViewById(R.id.surfaceView1));
mHolder=videoSView.getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
((Button)findViewById(R.id.startBtn)).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View arg0) {
if(startedRecording == false) {
recorder.start();
startedRecording = true;
Toast.makeText(NewRecordingVideo.this,
"Your video is recording", Toast.LENGTH_LONG).show();
} else if (startedRecording == true && stoppedRecording == false) {
recorder.stop();
recorder.release();
recorder = null;
stoppedRecording = true;
}
}
});
((Button)findViewById(R.id.stopBtn)).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
recorder.stop();
recorder.release();
recorder = null;
stoppedRecording = true;
Toast.makeText(NewRecordingVideo.this,
"Your video recorded ", Toast.LENGTH_LONG).show();
finish();
}
});
}
public Surface getSurface() {
return mHolder.getSurface();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
try {
Socket socket = new Socket("IP address", 8008);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
Log.v("find about connection","====>"+socket.isConnected());
recorder.setOutputFile("/sdcard/recording.3gp");
// Here I would like to record my video (recording.3gp) on helix server directly
recorder.setPreviewDisplay(mHolder.getSurface());
recorder.prepare();
} catch (Exception e) {
String message = e.getMessage();
recorder.release();
recorder = null;
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (recorder != null) {
recorder.release();
recorder = null;
}
}
}
从上面的代码:如何将我的视频录制文件直接保存在 Helix 服务器上?我应该在服务器端开发上做任何实现吗?