(Data SendVideoMsgParam)
| 21 | } |
| 22 | |
| 23 | func SendVideoMsg(Data SendVideoMsgParam) wxCilent.ResponseResult { |
| 24 | var err error |
| 25 | var protobufdata []byte |
| 26 | var errtype int64 |
| 27 | |
| 28 | D, err := comm.GetLoginata(Data.Wxid) |
| 29 | if err != nil { |
| 30 | return wxCilent.ResponseResult{ |
| 31 | Code: -8, |
| 32 | Success: false, |
| 33 | Message: fmt.Sprintf("异常:%v", err.Error()), |
| 34 | Data: nil, |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | VideoBuffer, _ := base64.StdEncoding.DecodeString(Data.Video) |
| 39 | ImageBuffer, _ := base64.StdEncoding.DecodeString(Data.Image) |
| 40 | |
| 41 | VideoStream := bytes.NewBuffer(VideoBuffer) |
| 42 | ImageStream := bytes.NewBuffer(ImageBuffer) |
| 43 | |
| 44 | Startpos := 0 |
| 45 | datalen := 65000 |
| 46 | videoTotalLength := VideoStream.Len() |
| 47 | imageTotalLength := ImageStream.Len() |
| 48 | |
| 49 | ClientImgId := fmt.Sprintf("%v_%v", Data.Wxid, time.Now().Unix()) |
| 50 | |
| 51 | I := 0 |
| 52 | J := 0 |
| 53 | |
| 54 | for { |
| 55 | Startpos = I * datalen |
| 56 | count := 0 |
| 57 | if videoTotalLength-Startpos > datalen { |
| 58 | count = datalen |
| 59 | } else { |
| 60 | count = videoTotalLength - Startpos |
| 61 | } |
| 62 | if count < 0 { |
| 63 | break |
| 64 | } |
| 65 | |
| 66 | Databuff := make([]byte, count) |
| 67 | _, _ = VideoStream.Read(Databuff) |
| 68 | |
| 69 | req := &mm.UploadVideoRequest{ |
| 70 | BaseRequest: &mm.BaseRequest{ |
| 71 | SessionKey: D.Sessionkey, |
| 72 | Uin: proto.Uint32(D.Uin), |
| 73 | DeviceId: D.Deviceid_byte, |
| 74 | ClientVersion: proto.Int32(int32(wxCilent.Wx_client_version)), |
| 75 | DeviceType: wxCilent.DeviceType_byte, |
| 76 | Scene: proto.Uint32(0), |
| 77 | }, |
| 78 | ClientMsgID: proto.String(ClientImgId), |
| 79 | FromUserName: proto.String(Data.Wxid), |
| 80 | ToUserName: proto.String(Data.ToWxid), |
no test coverage detected