github.com/CyCoreSystems/ari@v4.8.4+incompatible/client/native/liveRecording.go (about) 1 package native 2 3 import ( 4 "errors" 5 6 "github.com/CyCoreSystems/ari" 7 ) 8 9 // LiveRecording provides the ARI LiveRecording accessors for the native client 10 type LiveRecording struct { 11 client *Client 12 } 13 14 // Get gets a lazy handle for the live recording name 15 func (lr *LiveRecording) Get(key *ari.Key) (h *ari.LiveRecordingHandle) { 16 h = ari.NewLiveRecordingHandle(lr.client.stamp(key), lr, nil) 17 return 18 } 19 20 // Data retrieves the state of the live recording 21 func (lr *LiveRecording) Data(key *ari.Key) (d *ari.LiveRecordingData, err error) { 22 if key == nil || key.ID == "" { 23 return nil, errors.New("liveRecording key not supplied") 24 } 25 26 var data = new(ari.LiveRecordingData) 27 if err := lr.client.get("/recordings/live/"+key.ID, data); err != nil { 28 return nil, dataGetError(err, "liveRecording", "%v", key.ID) 29 } 30 31 data.Key = lr.client.stamp(key) 32 return data, nil 33 } 34 35 // Stop stops the live recording. 36 // 37 // NOTE: if the recording is already stopped, this will return an error. 38 func (lr *LiveRecording) Stop(key *ari.Key) error { 39 if key == nil || key.ID == "" { 40 return errors.New("liveRecording key not supplied") 41 } 42 43 return lr.client.post("/recordings/live/"+key.ID+"/stop", nil, nil) 44 } 45 46 // Pause pauses the live recording (TODO: does it error if the live recording is already paused) 47 func (lr *LiveRecording) Pause(key *ari.Key) error { 48 return lr.client.post("/recordings/live/"+key.ID+"/pause", nil, nil) 49 } 50 51 // Resume resumes the live recording (TODO: does it error if the live recording is already resumed) 52 func (lr *LiveRecording) Resume(key *ari.Key) error { 53 return lr.client.del("/recordings/live/"+key.ID+"/pause", nil, "") 54 } 55 56 // Mute mutes the live recording (TODO: does it error if the live recording is already muted) 57 func (lr *LiveRecording) Mute(key *ari.Key) error { 58 return lr.client.post("/recordings/live/"+key.ID+"/mute", nil, nil) 59 } 60 61 // Unmute unmutes the live recording (TODO: does it error if the live recording is already muted) 62 func (lr *LiveRecording) Unmute(key *ari.Key) error { 63 return lr.client.del("/recordings/live/"+key.ID+"/mute", nil, "") 64 } 65 66 // Scrap removes a live recording (TODO: describe difference between scrap and delete) 67 func (lr *LiveRecording) Scrap(key *ari.Key) error { 68 return lr.client.del("/recordings/live/"+key.ID, nil, "") 69 } 70 71 // Stored returns the StoredRecording handle for the given LiveRecording 72 func (lr *LiveRecording) Stored(key *ari.Key) *ari.StoredRecordingHandle { 73 return ari.NewStoredRecordingHandle( 74 lr.client.stamp(key.New(ari.StoredRecordingKey, key.ID)), 75 lr.client.StoredRecording(), 76 nil, 77 ) 78 } 79 80 // Subscribe is a shim to enable recording handles to subscribe to their 81 // underlying bridge/channel for events. It should not be called directly. 82 func (lr *LiveRecording) Subscribe(key *ari.Key, n ...string) ari.Subscription { 83 return lr.client.Bus().Subscribe(key, n...) 84 }