Documentation
¶
Index ¶
- type Canvas
- type ClientStartCloudPlayerRequest
- type ClientStartRtmpRequest
- type ClientStopPullRequest
- type ClientStopRtmpRequest
- type ClientUpdatePullRequest
- type ClientUpdateRtmpRequest
- type CloudPlayerStartRequest
- type CloudPlayerUpdateResponse
- type Converter
- type ConverterResponse
- type Customized
- type Layout
- type Player
- type PlayerResponse
- type PullAudioOptions
- type PullVideoOptions
- type PushAudioOptions
- type PushVideoOptions
- type RawOptions
- type Region
- type RtmpPushRequest
- type RtmpService
- func (s *RtmpService) AddTimestamp(response Timestampable) (json.RawMessage, error)
- func (s *RtmpService) GenerateUID() string
- func (s *RtmpService) GetPullList(c *gin.Context)
- func (s *RtmpService) GetPushList(c *gin.Context)
- func (s *RtmpService) HandleStartPullReq(startReq CloudPlayerStartRequest, region string, streamOriginIp *string, ...) (json.RawMessage, error)
- func (s *RtmpService) HandleStartPushReq(startReq RtmpPushRequest, region string, regionHintIp *string, ...) (json.RawMessage, error)
- func (s *RtmpService) HandleStopPullReq(playerId string, region string, requestID string) (json.RawMessage, error)
- func (s *RtmpService) HandleStopPushReq(converterId string, region string, requestID string) (json.RawMessage, error)
- func (s *RtmpService) HandleUpdatePullReq(updateReq CloudPlayerStartRequest, converterId string, region string, ...) (json.RawMessage, error)
- func (s *RtmpService) HandleUpdatePushReq(updateReq RtmpPushRequest, converterId string, region string, requestID string, ...) (json.RawMessage, error)
- func (s *RtmpService) RegisterRoutes(r *gin.Engine)
- func (s *RtmpService) StartPull(c *gin.Context)
- func (s *RtmpService) StartPush(c *gin.Context)
- func (s *RtmpService) StopPull(c *gin.Context)
- func (s *RtmpService) StopPush(c *gin.Context)
- func (s *RtmpService) UpdateConverter(c *gin.Context)
- func (s *RtmpService) UpdatePlayer(c *gin.Context)
- func (s *RtmpService) ValidateIdleTimeOut(idleTimeOut *int) *int
- func (s *RtmpService) ValidateRegion(regionToCheck string) bool
- type SeiOptions
- type Sink
- type Source
- type StartCloudPlayerResponse
- type StartRtmpResponse
- type StopRtmpResponse
- type Timestampable
- type TranscodeOptions
- type Vertical
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct {
Width int `json:"width"` // Width of the canvas in pixels
Height int `json:"height"` // Height of the canvas in pixels
}
Canvas defines the dimensions of the video canvas for transcoding.
type ClientStartCloudPlayerRequest ¶
type ClientStartCloudPlayerRequest struct {
ChannelName string `json:"channelName"` // The RTC channel name to push into
StreamUrl string `json:"streamUrl"` // The CDN/RTMP URL to pull from
Region string `json:"region"` // The region for the cloud player service
Uid *string `json:"uid,omitempty"` // (Optional) RTC stream UID to use for the cloud player instance
PlayerName *string `json:"name,omitempty"` // (Optional) name for the cloud player instance
StreamOriginIp *string `json:"streamOriginIp,omitempty"` // (Optional) The IP address of the media stream's origin server.
AudioOptions *PullAudioOptions `json:"audioOptions,omitempty"` // (Optional) audio transcoding configuration
VideoOptions *PullVideoOptions `json:"videoOptions,omitempty"` // (Optional) video transcoding options
IdleTimeOut *int `json:"idleTimeOut,omitempty"` // (Optional) idle timeout in seconds
PlayTs *int `json:"playTs,omitempty"` // (Optional) Unix timestamp (in seconds) when the cloud player starts playing the online media stream.
EncryptMode *string `json:"encryptMode,omitempty"` // (Optional) Encryption mode
}
ClientStartCloudPlayerRequest represents the JSON payload structure sent by the client to start an Cloud Player instance. It includes configuration details for the RTMP converter, stream settings, and (Optional) transcoding options.
type ClientStartRtmpRequest ¶
type ClientStartRtmpRequest struct {
ConverterName *string `json:"converterName,omitempty"` // (Optional) name for the RTMP converter
RtcChannel string `json:"rtcChannel"` // The RTC channel name to push from
StreamUrl string `json:"streamUrl"` // The RTMP server URL to push to
StreamKey string `json:"streamKey"` // The stream key for the RTMP server
Region string `json:"region"` // The region for the RTMP push service
RegionHintIp *string `json:"regionHintIp"` // (Optional) IP hint for region selection
UseTranscoding bool `json:"useTranscoding"` // Whether to use transcoding for the push
RtcStreamUid *string `json:"rtcStreamUid,omitempty"` // (Optional) RTC stream UID to push
AudioOptions *PushAudioOptions `json:"audioOptions,omitempty"` // (Optional) audio transcoding options
VideoOptions *PushVideoOptions `json:"videoOptions,omitempty"` // (Optional) video transcoding options
IdleTimeOut *int `json:"idleTimeOut,omitempty"` // (Optional) idle timeout in seconds
JitterBufferSizeMs *int `json:"jitterBufferSizeMs,omitempty"` // (Optional) jitter buffer size in milliseconds
}
ClientStartRtmpRequest represents the JSON payload structure sent by the client to start an RTMP push. It includes configuration details for the RTMP converter, stream settings, and (Optional) transcoding options.
type ClientStopPullRequest ¶
type ClientStopPullRequest struct {
PlayerId string `json:"playerId"` // The ID of the cloud player to stop
Region string `json:"region"` // The region where the RTMP push is running
}
ClientStopPullRequest represents the JSON payload structure for stopping an RTMP push. It contains the necessary identifiers to locate and terminate a specific RTMP push.
type ClientStopRtmpRequest ¶
type ClientStopRtmpRequest struct {
ConverterId string `json:"converterId"` // The ID of the RTMP converter to stop
Region string `json:"region"` // The region where the RTMP push is running
}
ClientStopRtmpRequest represents the JSON payload structure for stopping an RTMP push. It contains the necessary identifiers to locate and terminate a specific RTMP push.
type ClientUpdatePullRequest ¶
type ClientUpdatePullRequest struct {
PlayerId string `json:"playerId"` // The ID of the cloud player to update
Region string `json:"region"` // The region where the RTMP push is running
StreamUrl *string `json:"streamUrl"` // The CDN/RTMP server URL to pull from
AudioOptions *PullAudioOptions `json:"audioOptions,omitempty"` // (Optional) updated audio options
IsPause *bool `json:"isPause,omitempty"` // (Optional) updated jitter buffer size
SeekPosition *int `json:"seekPosition,omitempty"` // (Optional) Start playback at this position
SequenceId *int `json:"sequenceId,omitempty"` // (Optional) Agora server updates cloud player according to the latest sequence id
}
ClientUpdatePullRequest represents the JSON payload structure for updating an ongoing RTMP push. It allows for modifications to certain parameters of an active RTMP push.
type ClientUpdateRtmpRequest ¶
type ClientUpdateRtmpRequest struct {
ConverterId string `json:"converterId"` // The ID of the RTMP converter to update
Region string `json:"region"` // The region where the RTMP push is running
StreamUrl *string `json:"streamUrl"` // The RTMP server URL to push to
StreamKey *string `json:"streamKey"` // The stream key for the RTMP server
RtcChannel string `json:"rtcChannel"` // The RTC channel name (in case of change)
VideoOptions *PushVideoOptions `json:"videoOptions,omitempty"` // (Optional) updated video options
JitterBufferSizeMs *int `json:"jitterBufferSizeMs,omitempty"` // (Optional) updated jitter buffer size
SequenceId *int `json:"sequenceId,omitempty"` // (Optional) Agora server updates cloud player according to the latest sequence id
}
ClientUpdateRtmpRequest represents the JSON payload structure for updating an ongoing RTMP push. It allows for modifications to certain parameters of an active RTMP push.
type CloudPlayerStartRequest ¶
type CloudPlayerStartRequest struct {
Player Player `json:"player"` // The player configuration for the clout player instance
}
type CloudPlayerUpdateResponse ¶
type CloudPlayerUpdateResponse struct {
Status string `json:"status"` // Status of the stop request
Timestamp *string `json:"timestamp,omitempty"` // (Optional) timestamp for when the RTMP push was stopped
}
CloudPlayerUpdateResponse represents the response received from the Agora server after stopping an RTMP push. It includes a status message and an (Optional) timestamp.
func (*CloudPlayerUpdateResponse) SetTimestamp ¶
func (s *CloudPlayerUpdateResponse) SetTimestamp(timestamp string)
SetTimestamp implements the Timestampable interface for StopCloudPlayerResponse.
type Converter ¶
type Converter struct {
Name *string `json:"name,omitempty"` // (Optional) name for the converter
TranscodeOptions *TranscodeOptions `json:"transcodeOptions,omitempty"` // Options for transcoded push
RawOptions *RawOptions `json:"rawOptions,omitempty"` // Options for raw (non-transcoded) push
RtmpUrl *string `json:"rtmpUrl,omitempty"` // The RTMP URL to push to
IdleTimeOut *int `json:"idleTimeOut,omitempty"` // (Optional) idle timeout in seconds
JitterBufferSizeMs *int `json:"jitterBufferSizeMs,omitempty"` // (Optional) jitter buffer size in milliseconds
}
Converter represents the configuration for an RTMP converter. It includes settings for both transcoded and raw RTMP pushes.
type ConverterResponse ¶
type ConverterResponse struct {
ConverterId string `json:"id"` // Unique identifier for the converter
CreateTs int64 `json:"createTs"` // Timestamp of converter creation
UpdateTs int64 `json:"updateTs"` // Timestamp of last update
State string `json:"state"` // Current state of the converter
}
ConverterResponse contains the details of an RTMP converter returned by the Agora server.
type Customized ¶
type Customized struct {
PrefixForAgoraSei string `json:"prefixForAgoraSei"` // Prefix for Agora SEI
Payload string `json:"payload"` // Custom SEI payload
}
Customized defines custom SEI data.
type Layout ¶
type Layout struct {
RtcStreamUid string `json:"rtcStreamUid"` // UID of the RTC stream
Region Region `json:"region"` // Position and size within the canvas
FillMode string `json:"fillMode,omitempty"` // (Optional) fill mode for the video
PlaceholderImageUrl string `json:"placeholderImageUrl,omitempty"` // (Optional) placeholder image URL
}
Layout defines the position and size of a single stream within the video canvas.
type Player ¶
type Player struct {
AudioOptions *PullAudioOptions `json:"audioOptions,omitempty"` // (Optional) audio transcoding configuration
VideoOptions *PullVideoOptions `json:"videoOptions,omitempty"` // (Optional) video transcoding options
StreamUrl string `json:"streamUrl"` // The CDN/RTMP URL to pull from
ChannelName string `json:"channelName"` // The RTC channel name to push into
Token string `json:"token"` // The access token
Uid string `json:"uid"` // (Optional) RTC stream UID to use for the cloud player instance
IdleTimeOut *int `json:"idleTimeOut,omitempty"` // (Optional) idle timeout in seconds
PlayTs *int `json:"playTs,omitempty"` // (Optional) Unix timestamp (in seconds) when the cloud player starts playing the online media stream.
EncryptMode *string `json:"encryptMode,omitempty"` // (Optional) Encryption mode
IsPause *bool `json:"isPause,omitempty"` // (Optional) updated jitter buffer size
SeekPosition *int `json:"seekPosition,omitempty"` // (Optional) Start playback at this position
PlayerName *string `json:"name,omitempty"` // (Optional) name for the cloud player instance
}
type PlayerResponse ¶
type PlayerResponse struct {
PlayerId string `json:"id"` // Unique identifier for the cloud player
CreateTs int64 `json:"createTs"` // Timestamp of converter creation
Uid *string `json:"uid,omitempty"` // (Optional) RTC stream UID to use for the cloud player instance
}
ConverterResponse contains the details of an RTMP converter returned by the Agora server.
type PullAudioOptions ¶
type PullAudioOptions struct {
Profile *int `json:"profile,omitempty"` // Sets the audio profile sample rate, bitrate, encoding mode, and the number of channels [0-5]
Volume *int `json:"volume,omitempty"` // Sets the volume of the cloud player. The value range is [0,200]
}
PushAudioOptions specifies the audio transcoding settings for an RTMP push.
type PullVideoOptions ¶
type PullVideoOptions struct {
Width int `json:"width"` // Width of the canvas in pixels
Height int `json:"height"` // Height of the canvas in pixels
WidthHeightAdaption *bool `json:"widthHeightAdaption"` // Whether to enable horizontal and vertical screen adaptive mode (default: false)
FrameRate *int `json:"frameRate,omitempty"` // (Optional) frame rate
Bitrate int `json:"bitrate"` // Video bitrate in Kbps
Codec string `json:"codec"` // Video codec (H264 or VP9)
FillMode *string `json:"fillMode,omitempty"` // (Optional) The fill mode of the output video (fit/fill)
Gop *int `json:"gop,omitempty"` // (Optional) Group of Pictures (GOP) size
}
PullVideoOptions specifies the video transcoding settings for the cloud player. It includes layout, codec, and quality settings.
type PushAudioOptions ¶
type PushAudioOptions struct {
CodecProfile string `json:"codecProfile"` // Audio codec profile
SampleRate int `json:"sampleRate"` // Audio sample rate in Hz
Bitrate int `json:"bitrate"` // Audio bitrate in Kbps
AudioChannels int `json:"audioChannels"` // Number of audio channels
}
PushAudioOptions specifies the audio transcoding settings for an RTMP push.
type PushVideoOptions ¶
type PushVideoOptions struct {
Canvas Canvas `json:"canvas"` // Canvas dimensions for the video
Layout []Layout `json:"layout"` // Layout configuration for multiple streams
Vertical *Vertical `json:"vertical,omitempty"` // (Optional) vertical layout settings
DefaultPlaceholderImageUrl *string `json:"defaultPlaceholderImageUrl,omitempty"` // (Optional) default placeholder image URL
Codec *string `json:"codec,omitempty"` // (Optional) video codec
CodecProfile *string `json:"codecProfile,omitempty"` // (Optional) codec profile
FrameRate *int `json:"frameRate,omitempty"` // (Optional) frame rate
Gop *int `json:"gop,omitempty"` // (Optional) Group of Pictures (GOP) size
Bitrate int `json:"bitrate"` // Video bitrate in Kbps
SeiOptions *SeiOptions `json:"seiOptions,omitempty"` // (Optional) Supplemental Enhancement Information (SEI) options
}
PushVideoOptions specifies the video transcoding settings for an RTMP push. It includes layout, codec, and quality settings.
type RawOptions ¶
type RawOptions struct {
RtcChannel string `json:"rtcChannel"` // The RTC channel to push from
RtcStreamUid string `json:"rtcStreamUid"` // The UID of the RTC stream to push
}
RawOptions defines the parameters for a raw (non-transcoded) RTMP push.
type Region ¶
type Region struct {
XPos int `json:"xPos"` // X-axis position
YPos int `json:"yPos"` // Y-axis position
ZIndex int `json:"zIndex"` // Z-index for layering
Width int `json:"width"` // Width of the region
Height int `json:"height"` // Height of the region
}
Region defines the position and size of a video stream within the canvas.
type RtmpPushRequest ¶
type RtmpPushRequest struct {
Converter Converter `json:"converter"` // The converter configuration for the RTMP push instance
}
RtmpPushRequest defines the structure for a request to start or update an RTMP push to the Agora service. It encapsulates the converter configuration for the RTMP push.
type RtmpService ¶
type RtmpService struct {
// contains filtered or unexported fields
}
RtmpService represents the media push and pull services. It holds the necessary configurations and dependencies for managing Media Push & Pull with Agora Channels.
func NewRtmpService ¶
func NewRtmpService(appID string, baseURL string, rtmpURL string, cloudPlayerURL string, basicAuth string, tokenService *token_service.TokenService) *RtmpService
NewRtmpService returns a RtmpService pointer with all configurations set. This function initializes a new RtmpService with specified configurations. It ensures all provided parameters are valid and logs a fatal error if any required configurations are missing.
Parameters:
- appID: string - The Agora app ID.
- baseURL: string - The base URL for the Agora API.
- rtmpURL: string - The URL path for Agora's RTMP converter service.
- cloudPlayerURL: string - The URL path for Agora's Cloud Player service.
- basicAuth: string - The basic authentication credentials.
Returns:
- *RtmpService: The initialized RtmpService struct.
Behavior:
- Initializes and returns a RtmpService struct with the given configurations.
- Seeds the random number generator with the current time.
Notes:
- Logs a fatal error and exits if any required environment variables are missing.
func (*RtmpService) AddTimestamp ¶
func (s *RtmpService) AddTimestamp(response Timestampable) (json.RawMessage, error)
AddTimestamp adds a current timestamp to any response object that supports the Timestampable interface. It then marshals the updated object back into JSON format for further use or storage.
func (*RtmpService) GenerateUID ¶
func (s *RtmpService) GenerateUID() string
generateUID generates a unique user identifier for use within cloud recording sessions. This function ensures the UID is never zero, which is reserved, by generating a random number between 1 and the maximum possible 32-bit integer value.
func (*RtmpService) GetPullList ¶
func (s *RtmpService) GetPullList(c *gin.Context)
GetPullList returns a list of the current cloud players. It processes the request to get the current list of the media stream pull operations.
func (*RtmpService) GetPushList ¶
func (s *RtmpService) GetPushList(c *gin.Context)
GetPushList returns a list of the current RTMP converters. It processes the request to get the current list of the media stream pushing operations.
func (*RtmpService) HandleStartPullReq ¶
func (s *RtmpService) HandleStartPullReq(startReq CloudPlayerStartRequest, region string, streamOriginIp *string, requestID string) (json.RawMessage, error)
HandleStartPullReq initiates an RTMP push request using Agora's Media Push service. It validates the request parameters, constructs the request URL, and sends the start recording request to the Agora API using the makeRequest helper function.
Parameters:
- startReq: RtmpPushRequest - Contains the configuration settings for the RTMP push request.
- region: string - The region ID previously acquired to identify the resource for the recording.
- regionHintIp: *string - Optional parameter to provide a specific IP hint for the region.
- requestID: string - The unique request ID for tracing the request.
Returns:
- json.RawMessage: The raw JSON response containing the recording ID (sid) from Agora.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Constructs the URL for starting a new recording session based on the provided parameters.
- Appends the regionHintIp to the URL if provided and valid.
- Sends a POST request with the start recording configuration to the Agora endpoint.
- Parses the JSON response to extract and validate the recording ID.
- Appends a timestamp to the response for record-keeping before returning the modified response.
Notes:
- Assumes the presence of s.baseURL & s.cloudPlayerURL for constructing the request URL.
- Utilizes s.makeRequest for sending the HTTP request and handling the response.
- Utilizes s.isValidIPv4 for validating the regionHintIp.
- Utilizes s.AddTimestamp to append a timestamp to the response.
func (*RtmpService) HandleStartPushReq ¶
func (s *RtmpService) HandleStartPushReq(startReq RtmpPushRequest, region string, regionHintIp *string, requestID string) (json.RawMessage, error)
HandleStartPushReq initiates an RTMP push request using Agora's Media Push service. It validates the request parameters, constructs the request URL, and sends the start recording request to the Agora API using the makeRequest helper function.
Parameters:
- startReq: RtmpPushRequest - Contains the configuration settings for the RTMP push request.
- region: string - The region ID previously acquired to identify the resource for the recording.
- regionHintIp: *string - Optional parameter to provide a specific IP hint for the region.
- requestID: string - The unique request ID for tracing the request.
Returns:
- json.RawMessage: The raw JSON response containing the recording ID (sid) from Agora.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Constructs the URL for starting a new recording session based on the provided parameters.
- Appends the regionHintIp to the URL if provided and valid.
- Sends a POST request with the start recording configuration to the Agora endpoint.
- Parses the JSON response to extract and validate the recording ID.
- Appends a timestamp to the response for record-keeping before returning the modified response.
Notes:
- Assumes the presence of s.baseURL & s.rtmpURL for constructing the request URL.
- Utilizes s.makeRequest for sending the HTTP request and handling the response.
- Utilizes s.isValidIPv4 for validating the regionHintIp.
- Utilizes s.AddTimestamp to append a timestamp to the response.
func (*RtmpService) HandleStopPullReq ¶
func (s *RtmpService) HandleStopPullReq(playerId string, region string, requestID string) (json.RawMessage, error)
HandleStopPullReq stops an RTMP push request using Agora's Media Push service. It constructs the request URL and sends the stop request to the Agora API using the makeRequest helper function.
Parameters:
- playerId: string - The ID of the Cloud Player returned in the start pull request.
- region: string - The region ID previously acquired to identify the resource for the recording.
- requestID: string - The unique request ID for tracing the request.
Returns:
- json.RawMessage: The raw JSON response indicating the status of the stop request.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Constructs the URL for stopping the cloud player session based on the provided parameters.
- Sends a DELETE request to the Agora endpoint to stop the cloud player service.
- Creates a success response for the client as the successful response won't have a body.
- Appends a timestamp to the response for record-keeping before returning the modified response.
Notes:
- Assumes the presence of s.baseURL & s.cloudPlayerURL for constructing the request URL.
- Utilizes s.makeRequest for sending the HTTP request and handling the response.
- Utilizes s.AddTimestamp to append a timestamp to the response.
func (*RtmpService) HandleStopPushReq ¶
func (s *RtmpService) HandleStopPushReq(converterId string, region string, requestID string) (json.RawMessage, error)
HandleStopPushReq stops an RTMP push request using Agora's Media Push service. It constructs the request URL and sends the stop request to the Agora API using the makeRequest helper function.
Parameters:
- converterId: string - The ID of the Converter returned in the start push request.
- region: string - The region ID previously acquired to identify the resource for the recording.
- requestID: string - The unique request ID for tracing the request.
Returns:
- json.RawMessage: The raw JSON response indicating the status of the stop request.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Constructs the URL for stopping the recording session based on the provided parameters.
- Sends a DELETE request to the Agora endpoint to stop the recording.
- Creates a success response for the client as the successful response won't have a body.
- Appends a timestamp to the response for record-keeping before returning the modified response.
Notes:
- Assumes the presence of s.baseURL & s.rtmpURL for constructing the request URL.
- Utilizes s.makeRequest for sending the HTTP request and handling the response.
- Utilizes s.AddTimestamp to append a timestamp to the response.
func (*RtmpService) HandleUpdatePullReq ¶
func (s *RtmpService) HandleUpdatePullReq(updateReq CloudPlayerStartRequest, converterId string, region string, requestID string, sequenceId *int) (json.RawMessage, error)
HandleUpdatePullReq updates an existing RTMP push request using Agora's Media Push service. It constructs the request URL and sends the update request to the Agora API using the makeRequest helper function.
Parameters:
- updateReq: RtmpPushRequest - Contains the configuration settings for the update RTMP request.
- converterId: string - The ID of the Converter returned in the start push request.
- region: string - The region ID for the rtmp resource.
- requestID: string - The unique request ID for tracing the request.
Returns:
- json.RawMessage: The raw JSON response indicating the status of the update request.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Constructs the URL for updating the rtmp session based on the provided parameters.
- Sends a PATCH request to the Agora endpoint to update the rtmp resource.
- Creates a success response for the client as the successful response won't have a body.
- Appends a timestamp to the response for record-keeping before returning the modified response.
Notes:
- Assumes the presence of s.baseURL and s.rtmpURL for constructing the request URL.
- Utilizes s.makeRequest for sending the HTTP request and handling the response.
- Utilizes s.AddTimestamp to append a timestamp to the response.
func (*RtmpService) HandleUpdatePushReq ¶
func (s *RtmpService) HandleUpdatePushReq(updateReq RtmpPushRequest, converterId string, region string, requestID string, sequenceId *int) (json.RawMessage, error)
HandleUpdatePushReq updates an existing RTMP push request using Agora's Media Push service. It constructs the request URL and sends the update request to the Agora API using the makeRequest helper function.
Parameters:
- updateReq: RtmpPushRequest - Contains the configuration settings for the update RTMP request.
- converterId: string - The ID of the Converter returned in the start push request.
- region: string - The region ID for the rtmp resource.
- requestID: string - The unique request ID for tracing the request.
Returns:
- json.RawMessage: The raw JSON response indicating the status of the update request.
- error: Error object detailing any issues encountered during the API call.
Behavior:
- Constructs the URL for updating the rtmp session based on the provided parameters.
- Sends a PATCH request to the Agora endpoint to update the rtmp resource.
- Creates a success response for the client as the successful response won't have a body.
- Appends a timestamp to the response for record-keeping before returning the modified response.
Notes:
- Assumes the presence of s.baseURL and s.rtmpURL for constructing the request URL.
- Utilizes s.makeRequest for sending the HTTP request and handling the response.
- Utilizes s.AddTimestamp to append a timestamp to the response.
func (*RtmpService) RegisterRoutes ¶
func (s *RtmpService) RegisterRoutes(r *gin.Engine)
RegisterRoutes registers the routes for the RtmpService. It sets up the API endpoints for request handling.
Parameters:
- r: *gin.Engine - The Gin engine instance to register the routes with.
Behavior:
- Creates an API group for RTMP routes.
- Registers routes for starting push, stopping push, getting status, updating subscriber list, and updating layout.
Notes:
- This function organizes the API routes and ensures that requests are handled with appropriate middleware.
func (*RtmpService) StartPull ¶
func (s *RtmpService) StartPull(c *gin.Context)
StartPull handles the starting of an RTMP pull. It processes the request to start pulling the media stream from the specified RTMP URL into the given channel.
func (*RtmpService) StartPush ¶
func (s *RtmpService) StartPush(c *gin.Context)
StartPush handles the starting of an RTMP push. It processes the request to start pushing the media stream to the specified RTMP URL.
func (*RtmpService) StopPull ¶
func (s *RtmpService) StopPull(c *gin.Context)
StopPull handles the stopping of an RTMP push. It processes the request to stop pushing the media stream to the specified RTMP URL.
func (*RtmpService) StopPush ¶
func (s *RtmpService) StopPush(c *gin.Context)
StopPush handles the stopping of an RTMP push. It processes the request to stop pushing the media stream to the specified RTMP URL.
func (*RtmpService) UpdateConverter ¶
func (s *RtmpService) UpdateConverter(c *gin.Context)
UpdateConverter handles updating the transcoding options for the RTMP push. It processes the request to update the transcoding configuration for the media stream.
func (*RtmpService) UpdatePlayer ¶
func (s *RtmpService) UpdatePlayer(c *gin.Context)
UpdateConverter handles updating the transcoding options for the RTMP push. It processes the request to update the transcoding configuration for the media stream.
func (*RtmpService) ValidateIdleTimeOut ¶
func (s *RtmpService) ValidateIdleTimeOut(idleTimeOut *int) *int
checks if a given string is a valid IdleTimeout time.
func (*RtmpService) ValidateRegion ¶
func (s *RtmpService) ValidateRegion(regionToCheck string) bool
ValidateRegion checks if a specific string is present within a slice of strings. This is useful for determining if a particular item exists within a list.
type SeiOptions ¶
type SeiOptions struct {
Source Source `json:"source"` // SEI source options
Sink Sink `json:"sink"` // SEI sink options
}
SeiOptions defines options for Supplemental Enhancement Information (SEI) in the video stream.
type Sink ¶
type Sink struct {
Type int `json:"type"` // Type of SEI sink
}
Sink defines the SEI sink configuration.
type Source ¶
type Source struct {
Metadata bool `json:"metadata"` // Whether to include metadata
Datastream bool `json:"datastream"` // Whether to include datastream
Customized *Customized `json:"customized,omitempty"` // (Optional) custom SEI data
}
Source defines the SEI source configuration.
type StartCloudPlayerResponse ¶
type StartCloudPlayerResponse struct {
Player PlayerResponse `json:"player"` // Details of the newly created cloud player
Fields string `json:"fields"` // Additional fields returned by the server
Timestamp *string `json:"timestamp,omitempty"` // (Optional) timestamp for when the RTMP push was started
}
StartCloudPlayerResponse represents the response received from the Agora server after successfully starting an RTMP push. It includes details about the created converter and an (Optional) timestamp.
func (*StartCloudPlayerResponse) SetTimestamp ¶
func (s *StartCloudPlayerResponse) SetTimestamp(timestamp string)
SetTimestamp implements the Timestampable interface for StartCloudPlayerResponse.
type StartRtmpResponse ¶
type StartRtmpResponse struct {
Converter ConverterResponse `json:"converter"` // Details of the newly created RTMP converter
Fields string `json:"fields"` // Additional fields returned by the server
Timestamp *string `json:"timestamp,omitempty"` // (Optional) timestamp for when the RTMP push was started
}
StartRtmpResponse represents the response received from the Agora server after successfully starting an RTMP push. It includes details about the created converter and an (Optional) timestamp.
func (*StartRtmpResponse) SetTimestamp ¶
func (s *StartRtmpResponse) SetTimestamp(timestamp string)
SetTimestamp implements the Timestampable interface for StartRtmpResponse.
type StopRtmpResponse ¶
type StopRtmpResponse struct {
Status string `json:"status"` // Status of the stop operation
Timestamp *string `json:"timestamp,omitempty"` // (Optional) timestamp for when the RTMP push was stopped
}
StopRtmpResponse represents the response received from the Agora server after stopping an RTMP push. It includes a status message and an (Optional) timestamp.
func (*StopRtmpResponse) SetTimestamp ¶
func (s *StopRtmpResponse) SetTimestamp(timestamp string)
SetTimestamp implements the Timestampable interface for StopRtmpResponse.
type Timestampable ¶
type Timestampable interface {
SetTimestamp(timestamp string)
}
Timestampable is an interface that allows struct types to receive a timestamp. Implementing this interface ensures that a timestamp can be set on the object, primarily for auditing or tracking purposes.
type TranscodeOptions ¶
type TranscodeOptions struct {
RtcChannel string `json:"rtcChannel"` // The RTC channel to push from
AudioOptions *PushAudioOptions `json:"audioOptions,omitempty"` // Audio transcoding options
VideoOptions *PushVideoOptions `json:"videoOptions,omitempty"` // Video transcoding options
}
TranscodeOptions defines the parameters for a transcoded RTMP push. It includes audio and video transcoding options.