Agora RTC Objective-C API Reference Refactor

Public Member Functions
IMediaStreamingSource Class Referenceabstract

Inherits RefCountInterface.

## Public Member Functions
virtual int | open (const char *url, int64_t start_pos, bool auto_play=true)=0
virtual int | close ()=0
virtual int | getSourceId () const =0
virtual bool | isVideoValid ()=0
virtual bool | isAudioValid ()=0
virtual int | getDuration (int64_t &duration)=0
virtual int | getStreamCount (int64_t &count)=0
virtual int | getStreamInfo (int64_t index, media::base::PlayerStreamInfo *out_info)=0
virtual int | setLoopCount (int64_t loop_count)=0
virtual int | play ()=0
virtual int | pause ()=0
virtual int | stop ()=0
virtual int | seek (int64_t new_pos)=0
virtual int | getCurrPosition (int64_t &pos)=0
virtual STREAMING_SRC_STATE | getCurrState ()=0
virtual int | appendSeiData (const InputSeiData &inSeiData)=0
virtual int | registerObserver (IMediaStreamingSourceObserver *observer)=0
virtual int | unregisterObserver (IMediaStreamingSourceObserver *observer)=0
virtual int | parseMediaInfo (const char *url, media::base::PlayerStreamInfo &video_info, media::base::PlayerStreamInfo &audio_info)=0

## Constructor & Destructor Documentation

## ◆ ~IMediaStreamingSource()

virtual ~IMediaStreamingSource | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ open()

virtual int open | ( | const char * | url,
|  | int64_t | start_pos,
|  | bool | auto_play = `true`
| ) |  |
| pure virtual

Opens a media streaming source with a specified URL.

Parameters

  url | The path of the media file. Both the local path and online path are supported.
  startPos | The starting position (ms) for pushing. Default value is 0.
  auto_play | whether start playing after opened

Returns
  - 0: Success.
  - < 0: Failure

## ◆ close()

virtual int close | ( |  | ) |
| pure virtual

Close current media streaming source.

Returns
  - 0: Success.
  - < 0: Failure

## ◆ getSourceId()

virtual int getSourceId | ( |  | ) | const
| pure virtual

Gets the unique source ID of the streaming source.

Returns
  - ≧ 0: The source ID of this media player source.
  - < 0: Failure.

## ◆ isVideoValid()

virtual bool isVideoValid | ( |  | ) |
| pure virtual

Retrieve whether video stream is valid.

Returns
  : valid or invalid

## ◆ isAudioValid()

virtual bool isAudioValid | ( |  | ) |
| pure virtual

Retrieve whether audio stream is valid.

Returns
  : valid or invalid

## ◆ getDuration()

virtual int getDuration | ( | int64_t & | duration | ) |
| pure virtual

Gets the duration of the streaming source.

Parameters

  [out] | duration | A reference to the duration of the media file.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ getStreamCount()

virtual int getStreamCount | ( | int64_t & | count | ) |
| pure virtual

Gets the number of the streming source.

Parameters

  [out] | count | The number of the media streams in the media source.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ getStreamInfo()

virtual int getStreamInfo | ( | int64_t | index,
|  | media::base::PlayerStreamInfo * | out_info
| ) |  |
| pure virtual

Gets the detailed information of a media stream.

Parameters

  | index | The index of the media stream.
  [out] | out_info | The detailed information of the media stream. See PlayerStreamInfo for details.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ setLoopCount()

virtual int setLoopCount | ( | int64_t | loop_count | ) |
| pure virtual

Sets whether to loop the streaming source for playback.

Parameters

  loop_count | The number of times of looping the media file. 1: Play the media file once. 2: Play the media file twice. <= 0: Play the media file in a loop indefinitely, until stop is called.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ play()

virtual int play | ( |  | ) |
| pure virtual

Play & push the streaming source.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ pause()

virtual int pause | ( |  | ) |
| pure virtual

Pauses the playing & pushing of the streaming source, Keep current position.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ stop()

virtual int stop | ( |  | ) |
| pure virtual

Stop the playing & pushing of the streaming source, set the position to 0.

Returns
  - 0: Success.
  - < 0: Failure.See STREAMINGSRC_ERR.

## ◆ seek()

virtual int seek | ( | int64_t | new_pos | ) |
| pure virtual

Sets the playback position of the streaming source. After seek done, it will return to previous status.

Parameters

  newPos | The new playback position (ms).

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ getCurrPosition()

virtual int getCurrPosition | ( | int64_t & | pos | ) |
| pure virtual

Gets the current playback position of the media file.

Parameters

  [out] | pos | A reference to the current playback position (ms).

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ getCurrState()

virtual STREAMING_SRC_STATE getCurrState | ( |  | ) |
| pure virtual

@breif Gets the status of current streaming source.

Returns
  The current state machine

## ◆ appendSeiData()

virtual int appendSeiData | ( | const InputSeiData & | inSeiData | ) |
| pure virtual

append the SEI data which can be sent attached to video packet

Parameters

  type | SEI type
  timestamp | the video frame timestamp which attached to
  frame_index | the video frame timestamp which attached to

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ registerObserver()

virtual int registerObserver | ( | IMediaStreamingSourceObserver * | observer | ) |
| pure virtual

Registers a media player source observer.

Once the media player source observer is registered, you can use the observer to monitor the state change of the media player.

Parameters

  observer | The pointer to the IMediaStreamingSource object.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ unregisterObserver()

virtual int unregisterObserver | ( | IMediaStreamingSourceObserver * | observer | ) |
| pure virtual

Releases the media player source observer.

Parameters

  observer | The pointer to the IMediaStreamingSource object.

Returns
  - 0: Success.
  - < 0: Failure. See STREAMINGSRC_ERR.

## ◆ parseMediaInfo()

virtual int parseMediaInfo | ( | const char * | url,
|  | media::base::PlayerStreamInfo & | video_info,
|  | media::base::PlayerStreamInfo & | audio_info
| ) |  |
| pure virtual

Parse a media information with a specified URL.

Parameters

  url | : The path of the media file. Both the local path and online path are supported.
  video_info | : The output video information, It means no video track while video_info.streamIndex less than 0
  audio_info | : The output audio information, It means no audio track while audio_info.streamIndex less than 0

Returns
  - 0: Success.
  - < 0: Failure

## ◆ AddRef()

virtual void AddRef | ( |  | ) | const
| pure virtual inherited

## ◆ Release()

virtual RefCountReleaseStatus Release | ( |  | ) | const
| pure virtual inherited

## ◆ HasOneRef()

virtual bool HasOneRef | ( |  | ) | const
| pure virtual inherited