func GetStreamPlayResult(sessionId, accessToken, publishId string, pResult *StreamPlayResult) { if _, valid := CheckAuthValid(sessionId, accessToken, &pResult.ApiResult); !valid { return } if publishId == "" { pResult.SetFormatCode(API_PARAM_ERROR, "publish id is empty") return } liveVideo := model.LiveVideo{} qErr := model.GetLiveVideoByPublishId(publishId, &liveVideo) if qErr != nil { pResult.SetCode(API_SERVER_ERROR) return } if liveVideo.Id == 0 { pResult.SetCode(API_NO_VIDEO_FOUND_ERROR) return } playUrls, gErr := pilis.GetLivePlayUrl(liveVideo.StreamId) if gErr != nil { pResult.SetCode(API_SERVER_ERROR) return } pResult.PlayUrls = playUrls pResult.Orientation = liveVideo.Orientation pResult.SetOk() return }
func GetVideoPlayResult(sessionId, accessToken, publishId string, pResult *VideoPlayResult) { if _, valid := CheckAuthValid(sessionId, accessToken, &pResult.ApiResult); !valid { return } if publishId == "" { pResult.SetFormatCode(API_PARAM_ERROR, "publish id is empty") return } liveVideo := model.LiveVideo{} qErr := model.GetLiveVideoByPublishId(publishId, &liveVideo) if qErr != nil { log.Error("get live video by publish id error", qErr) pResult.SetCode(API_SERVER_ERROR) return } if liveVideo.Id == 0 { pResult.SetCode(API_NO_VIDEO_FOUND_ERROR) return } playUrls, gErr := pilis.GetPlaybackUrl(liveVideo.StreamId, liveVideo.StartTime, liveVideo.EndTime) if gErr != nil { log.Error("pili get playback url error", gErr) pResult.SetCode(API_SERVER_ERROR) return } pResult.PlayUrls = playUrls pResult.Orientation = liveVideo.Orientation pResult.SetOk() return }