kurento7.1.0框架中,把WebRtcEndpoint的音视频流通过HttpPostEndpoint推送到http服务器接口,该如何实现,需要哪些配置。
核心代码:
信令服务器的核心代码如下:
```java
pipeline = kurento.createMediaPipeline();
webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build();
webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build();
httpPostEndpoint = new HttpPostEndpoint.Builder(pipeline)
.with("url", "http://192.168.0.149:8088/api/stream")
//.with("contentType", "video/webm")
//.with("useEncodedMedia", true)
.build();
webRtcCaller.connect(webRtcCallee); //呼叫者信息传送给被呼叫者
webRtcCallee.connect(httpPostEndpoint); **//被呼叫者的连接到HttpPostEndpoint,(想实现把被呼叫者的音视频发送http://192.168.0.149:8088/api/stream,但没有成功,请问这是为啥,)**
webRtcCallee.addMediaFlowInStateChangedListener(event -> { //该回调函数会执行,表明webRtcCallee有数据流入
System.out.println("CalleeWebRtcEp 媒体流入状态: " + event.getState());
System.out.println("CalleeWebRtcEp 媒体类型: " + event.getMediaType());
});
webRtcCallee.addMediaFlowOutStateChangedListener(event->{ //该回调函数会执行,表明webRtcCallee有数据流出
System.out.println("CalleeWebRtcEp 媒体流出状态: " + event.getState());
System.out.println("CalleeWebRtcEp 媒体类型: " + event.getMediaType());
});
httpPostEndpoint.addMediaFlowInStateChangedListener(event -> { //该回调函数不会执行,表明httpPostEndpoint没有数据流入
System.out.println("HttpPostEndpoint 媒体流入状态: " + event.getState());
System.out.println("HttpPostEndpoint媒体类型: " + event.getMediaType());
});
httpPostEndpoint.addMediaFlowOutStateChangedListener(event->{ //该回调函数不会执行,表明httpPostEndpoint没有数据流出
System.out.println("HttpPostEndpoint 媒体流出状态: " + event.getState());
System.out.println("HttpPostEndpoint媒体类型: " + event.getMediaType());
});
接口核心代码如下:
@PostMapping(value = "/api/stream", consumes = "video/webm")
public ResponseEntity<String> handleStream(@RequestBody byte[] data) {
System.out.println("接收到数据, 大小: " + data.length + " bytes");
// 保存到文件
try (FileOutputStream fos = new FileOutputStream("D:/tmp/received.webm", true)) {
fos.write(data);
return ResponseEntity.ok("数据接收成功");
} catch (IOException e) {
e.printStackTrace();
return ResponseEntity.status(500).body("数据接收失败");
}
}
该如何修改上面的代码,才能实现把被呼叫者的音视频发送http://192.168.0.149:8088/api/stream?kurento-media-server媒体服务器需要做修改吗?