func (p *Peer) Offer(msg *proto.ClientOfferMsg) (interface{}, error) {
	log.Infof("peer offer: uid=%s, msg=%v", p.uid, msg)

	// send offer to sfu
	sfu, err := p.sfu()
	if err != nil {
		return nil, err
	}
	resp, err := p.s.nrpc.Request(sfu, proto.SfuOfferMsg{
		MID:  p.mid,
		Desc: msg.Desc,
	})
	if err != nil {
		log.Errorf("offer %s failed %v", sfu, err.Error())
		return nil, err
	}

	// associate the stream in the SDP with the UID/SID/MID.
	sdpInfo, err := sdp.Parse(msg.Desc.SDP)
	if err != nil {
		log.Errorf("parse sdp error: %v", err)
	}
	for key := range sdpInfo.GetStreams() {
		if err := p.s.nrpc.Publish(p.s.islb, proto.ToIslbStreamAddMsg{
			UID: p.uid, SID: p.sid, MID: p.mid, StreamID: proto.StreamID(key),
		}); err != nil {
			log.Errorf("send stream-add to %s error: %v", p.s.islb, err)
		}
	}

	// avp sub streams
	var avp string
	if len(p.s.elements) > 0 {
		if avp, err = p.avp(); err != nil {
			log.Errorf("get avp-node error: %v", err)
		}
	}
	if avp != "" {
		if err != nil {
			log.Errorf("parse sdp error: %v", err)
		}
		for _, eid := range p.s.elements {
			for _, stream := range sdpInfo.GetStreams() {
				tracks := stream.GetTracks()
				for _, track := range tracks {
					err = p.s.nrpc.Publish(avp, proto.ToAvpProcessMsg{
						Addr:   sfu,
						PID:    stream.GetID(),
						SID:    string(p.sid),
						TID:    track.GetID(),
						EID:    eid,
						Config: []byte{},
					})
					if err != nil {
						log.Errorf("avp process failed %v", err)
					}
				}
			}
		}
	}

	return resp.(*proto.SfuAnswerMsg).Desc, nil
}
// Offer client send Offer to biz
Offer client send Offer to biz
// Offer client send Offer to biz
func (p *Peer) Offer(msg *proto.ClientOfferMsg) (interface{}, error) {
	log.Infof("peer offer: uid=%s, msg=%v", p.uid, msg)
	sfu, err := p.sfu()
	if err != nil {
		return nil, err
	}
	resp, err := p.s.nrpc.Request(sfu, proto.SfuOfferMsg{
		MID:  p.mid,
		Desc: msg.Desc,
	})
	if err != nil {
		log.Errorf("offer %s failed %v", sfu, err.Error())
		return nil, err
	}
	sdpInfo, err := sdp.Parse(msg.Desc.SDP)
	if err != nil {
		log.Errorf("parse sdp error: %v", err)
	}
	for key := range sdpInfo.GetStreams() {
		if err := p.s.nrpc.Publish(p.s.islb, proto.ToIslbStreamAddMsg{
			UID: p.uid, SID: p.sid, MID: p.mid, StreamID: proto.StreamID(key),
		}); err != nil {
			log.Errorf("send stream-add to %s error: %v", p.s.islb, err)
		}
	}
	var avp string
	if len(p.s.elements) > 0 {
		if avp, err = p.avp(); err != nil {
			log.Errorf("get avp-node error: %v", err)
		}
	}
	if avp != "" {
		if err != nil {
			log.Errorf("parse sdp error: %v", err)
		}
		for _, eid := range p.s.elements {
			for _, stream := range sdpInfo.GetStreams() {
				tracks := stream.GetTracks()
				for _, track := range tracks {
					err = p.s.nrpc.Publish(avp, proto.ToAvpProcessMsg{
						Addr:   sfu,
						PID:    stream.GetID(),
						SID:    string(p.sid),
						TID:    track.GetID(),
						EID:    eid,
						Config: []byte{},
					})
					if err != nil {
						log.Errorf("avp process failed %v", err)
					}
				}
			}
		}
	}
	return resp.(*proto.SfuAnswerMsg).Desc, nil
}
func ( p * Peer ) Offer ( msg * proto . ClientOfferMsg ) ( interface { } , error ) { log . Infof ( " " , p . uid , msg ) sfu , err := p . sfu ( ) if err != nil { return nil , err } resp , err := p . s . nrpc . Request ( sfu , proto . SfuOfferMsg { MID : p . mid , Desc : msg . Desc , } ) if err != nil { log . Errorf ( " " , sfu , err . Error ( ) ) return nil , err } sdpInfo , err := sdp . Parse ( msg . Desc . SDP ) if err != nil { log . Errorf ( " " , err ) } for key := range sdpInfo . GetStreams ( ) { if err := p . s . nrpc . Publish ( p . s . islb , proto . ToIslbStreamAddMsg { UID : p . uid , SID : p . sid , MID : p . mid , StreamID : proto . StreamID ( key ) , } ) ; err != nil { log . Errorf ( " " , p . s . islb , err ) } } var avp string if len ( p . s . elements ) > 0 { if avp , err = p . avp ( ) ; err != nil { log . Errorf ( " " , err ) } } if avp != " " { if err != nil { log . Errorf ( " " , err ) } for _ , eid := range p . s . elements { for _ , stream := range sdpInfo . GetStreams ( ) { tracks := stream . GetTracks ( ) for _ , track := range tracks { err = p . s . nrpc . Publish ( avp , proto . ToAvpProcessMsg { Addr : sfu , PID : stream . GetID ( ) , SID : string ( p . sid ) , TID : track . GetID ( ) , EID : eid , Config : [ ] byte { } , } ) if err != nil { log . Errorf ( " " , err ) } } } } } return resp . ( * proto . SfuAnswerMsg ) . Desc , nil }
Offer client send Offer to biz
Offer client send Offer to biz
// send offer to sfu // associate the stream in the SDP with the UID/SID/MID. // avp sub streams