直播相关接口
parent
ee91708aa3
commit
6e4667475b
|
|
@ -71,5 +71,274 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换相机
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<int>> ExchangeCamera(string camera,int position,string videoId)
|
||||
{
|
||||
Response<int> response = new Response<int>();
|
||||
try
|
||||
{
|
||||
|
||||
var topicRequest = $"thing/product/8UUXN5400A079H/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_camera_change",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
camera_position = position,
|
||||
video_id = "8UUXN5400A079H/165-0-7/normal-0"
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply";
|
||||
var requestData1 = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_camera_change",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
result = 0
|
||||
}
|
||||
};
|
||||
string payload1 = JsonSerializer.Serialize(requestData1);
|
||||
await _mqttClientManager.PublishAsync(topicRequest1, payload1);
|
||||
|
||||
response.Result = 1;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response; ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置直播镜头
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<int>> SetCamera(string cameraType, string videoId)
|
||||
{
|
||||
Response<int> response = new Response<int>();
|
||||
try
|
||||
{
|
||||
|
||||
var topicRequest = $"thing/product/8UUXN5400A079H/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_lens_change",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
video_type = cameraType,
|
||||
video_id = "8UUXN5400A079H/165-0-7/normal-0"
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply";
|
||||
var requestData1 = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_lens_change",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
result = 0
|
||||
}
|
||||
};
|
||||
string payload1 = JsonSerializer.Serialize(requestData1);
|
||||
await _mqttClientManager.PublishAsync(topicRequest1, payload1);
|
||||
|
||||
response.Result = 1;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置直播清晰度
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<int>> SetCameraVideo(int videoQuality, string videoId)
|
||||
{
|
||||
Response<int> response = new Response<int>();
|
||||
try
|
||||
{
|
||||
|
||||
var topicRequest = $"thing/product/8UUXN5400A079H/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_set_quality",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
video_quality = videoQuality,
|
||||
video_id = "8UUXN5400A079H/165-0-7/normal-0"
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply";
|
||||
var requestData1 = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_set_quality",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
result = 0
|
||||
}
|
||||
};
|
||||
string payload1 = JsonSerializer.Serialize(requestData1);
|
||||
await _mqttClientManager.PublishAsync(topicRequest1, payload1);
|
||||
|
||||
response.Result = 1;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 停止直播
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<int>> EndLive( string videoId)
|
||||
{
|
||||
Response<int> response = new Response<int>();
|
||||
try
|
||||
{
|
||||
|
||||
var topicRequest = $"thing/product/8UUXN5400A079H/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_stop_push",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
|
||||
video_id = "8UUXN5400A079H/165-0-7/normal-0"
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
var topicRequest1 = $"thing/product/8UUXN5400A079H/services_reply";
|
||||
var requestData1 = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_start_push",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
result = 0
|
||||
}
|
||||
};
|
||||
string payload1 = JsonSerializer.Serialize(requestData1);
|
||||
await _mqttClientManager.PublishAsync(topicRequest1, payload1);
|
||||
|
||||
response.Result = 1;
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开始直播
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Response<int>> StartLive(string videoId,int urlType,string url,int quality)
|
||||
{
|
||||
Response<int> response = new Response<int>();
|
||||
try
|
||||
{
|
||||
|
||||
var topicRequest = $"thing/product/8UUXN5400A079H/services";
|
||||
var requestData = new
|
||||
{
|
||||
bid = Guid.NewGuid().ToString(),
|
||||
method = "live_start_push",
|
||||
tid = Guid.NewGuid().ToString(),
|
||||
timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
data = new
|
||||
{
|
||||
url_type = urlType,
|
||||
url = url,
|
||||
video_quality = quality,
|
||||
video_id = "8UUXN5400A079H/165-0-7/normal-0"
|
||||
}
|
||||
};
|
||||
string payload = JsonSerializer.Serialize(requestData);
|
||||
await _mqttClientManager.PublishAsync(topicRequest, payload);
|
||||
|
||||
|
||||
|
||||
response.Result = 1;
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Code = 500;
|
||||
response.Message = ex.Message;
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue