public async Task <string> StopVideo() { // Stop recording // ->{"msg_id":514,"token":1} // <-{"rval":0,"msg_id":514,"param":"/tmp/fuse_d/DCIM/100MEDIA/SJCM0003.mp4"} // <-{ "msg_id": 7, "type": "video_record_complete" ,"param":"/tmp/fuse_d/DCIM/100MEDIA/SJCM0003.mp4"} UserStopVideoMessage UsrMsg = new UserStopVideoMessage(_token); UserStopVideoMessageCodec UsrCodec = new UserStopVideoMessageCodec(); // Send the message string MsgSent = await UsrCodec.Encode(UsrMsg); if (await Send(MsgSent)) { // Receive the echo message string MsgReceived = await _CameraSocket.Receive(); CamParamMessageCodec CamEchoCodec = new CamParamMessageCodec(); CamParamMessage CamEchoMsg = await CamEchoCodec.Decode(MsgReceived); if (CamEchoMsg.msg_id != UsrMsg.msg_id) { return(null); } //Receive the video completed message MsgReceived = await _CameraSocket.Receive(); CamCaptureDoneMessageCodec CptrDoneCodec = new CamCaptureDoneMessageCodec(); CamCaptureDoneMessage CptrDoneMsg = await CptrDoneCodec.Decode(MsgReceived); // Check if msg_id and type are the expected if (CptrDoneMsg.msg_id != CamCaptureDoneMessage.msg_id_expected && !CptrDoneMsg.type.Equals(CamCaptureDoneMessage.video_expected)) { return(null); } _recording = false; // Return the location of the taken photo return(GetMediaLocation(CptrDoneMsg.param)); } return(null); }
/// <summary> /// Set the value of a parameter /// </summary> public async Task <bool> SetParamValue(string param, string value, string permission) { // If not settable request permission if (!permission.Equals("settable")) { // If permission not granted/error return null if (!await RequestPermission()) { return(false); } } // If everything ok continue // Create the message UserSetParamMessage UserMsg = new UserSetParamMessage(_token, param, value); // Get the codec UserSetParamMessageCodec UsrMsgCodec = new UserSetParamMessageCodec(); // Send the message if (await Send(await UsrMsgCodec.Encode(UserMsg))) { // If sent, get the response string MsgReceived = await _CameraSocket.Receive(); // Get the codec CamParamMessageCodec CamMsgCodec = new CamParamMessageCodec(); // Decode the string CamParamMessage CamMsg = await CamMsgCodec.Decode(MsgReceived); if (CamMsg.rval != 0 || CamMsg.msg_id != UserMsg.msg_id) { return(false); } return(true); } // If there is a problem return(false); }