微信小程序\推拉流
This commit is contained in:
@@ -59,9 +59,10 @@ type WebRTCICERequest struct {
|
||||
type JoinCallRoomResponse struct {
|
||||
RoomID string `json:"room_id"`
|
||||
Platform string `json:"platform"`
|
||||
ICEServers []ICEServerConfig `json:"ice_servers,omitempty"` // H5/App 用
|
||||
PushURL string `json:"push_url,omitempty"` // 小程序用
|
||||
PullURLs []PullURLInfo `json:"pull_urls,omitempty"` // 小程序用
|
||||
ICEServers []ICEServerConfig `json:"ice_servers,omitempty"` // H5/App 用
|
||||
FlvPullURLs []PullURLInfo `json:"flv_pull_urls,omitempty"` // H5/App 拉取小程序流的 FLV 地址
|
||||
PushURL string `json:"push_url,omitempty"` // 小程序用
|
||||
PullURLs []PullURLInfo `json:"pull_urls,omitempty"` // 小程序用
|
||||
Participants []ParticipantInfo `json:"participants"`
|
||||
}
|
||||
|
||||
@@ -164,6 +165,20 @@ func JoinCallRoomHandler(c *gin.Context) {
|
||||
// 返回 ICE 服务器配置
|
||||
response.ICEServers = getICEServers(req.UserID)
|
||||
|
||||
// 获取房间内小程序用户的 FLV 拉流地址(用于 Web 端播放小程序流)
|
||||
flvPullURLs := make([]PullURLInfo, 0)
|
||||
for _, p := range room.GetOtherParticipants(req.UserID) {
|
||||
// 只返回小程序用户的 FLV 地址
|
||||
if p.Type == mediaserver.ParticipantTypeRTMP && p.FLVURL != "" {
|
||||
flvPullURLs = append(flvPullURLs, PullURLInfo{
|
||||
UserID: p.UserID,
|
||||
URL: p.PullURL, // RTMP 地址
|
||||
FLVURL: p.FLVURL, // HTTP-FLV 地址
|
||||
})
|
||||
}
|
||||
}
|
||||
response.FlvPullURLs = flvPullURLs
|
||||
|
||||
case "miniprogram":
|
||||
// 小程序使用 RTMP
|
||||
pType := mediaserver.ParticipantTypeRTMP
|
||||
@@ -187,9 +202,10 @@ func JoinCallRoomHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 更新参与者的流地址
|
||||
room.SetParticipantRTMPURLs(req.UserID, stream.PushURL, stream.PullURL, stream.ID)
|
||||
room.SetParticipantRTMPURLs(req.UserID, stream.PushURL, stream.PullURL, stream.FLVURL, stream.ID)
|
||||
participant.PushURL = stream.PushURL
|
||||
participant.PullURL = stream.PullURL
|
||||
participant.FLVURL = stream.FLVURL
|
||||
participant.StreamID = stream.ID
|
||||
|
||||
response.PushURL = stream.PushURL
|
||||
@@ -201,6 +217,7 @@ func JoinCallRoomHandler(c *gin.Context) {
|
||||
pullURLs = append(pullURLs, PullURLInfo{
|
||||
UserID: p.UserID,
|
||||
URL: p.PullURL,
|
||||
FLVURL: p.FLVURL,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user