libquvi
 All Files Functions Typedefs Enumerations Enumerator Macros Groups Pages
Selecting a media stream

When the library returns >1 media streams, you can access them using the quvi_media_stream_next and quvi_media_get as described in Parsing media properties. Alternatively, the convenience functions quvi_media_stream_choose_best and quvi_media_stream_select could also be used.

abort_if_error();
{
char *m_url;
quvi_media_get(qm, QUVI_MEDIA_STREAM_PROPERTY_URL, &m_url);
}

In the above example, we tell the library to choose the stream that was determined (by the media script) to be of the best quality.

In the example below, we are only interested in a specific stream with the specified stream ID ("foo"). If it is not found (matched), the library falls back to the default stream.

abort_if_error();
{
char *m_url;
abort_if_error(); /* Always check quvi_ok return value with the above. */
quvi_media_get(qm, QUVI_MEDIA_STREAM_PROPERTY_URL, &m_url);
}

Since quvi_media_stream_select takes regular expression patterns, the following is also possible:

quvi_media_stream_select(qm, "\\w+_\\d+p$");

The value may also be a comma-separated list of patterns, e.g.:

quvi_media_stream_select(qm, "foo,bar,baz,croak");
abort_if_error(); /* Always check quvi_ok return value with the above. */
quvi_media_get(qm, QUVI_MEDIA_STREAM_PROPERTY_URL, &m_url);

Make a note of the use of the 'croak' keyword. This would cause the library to return an error if it was reached, e.g. none of the first three patterns matched any of the available Media stream ID. This is also the reason why an application should always quvi_ok after calling quvi_media_stream_select and handle the error, if any.

Refer to the API documentation of quvi_media_stream_select for more details.

See Also
quvi_media_stream_select
Media stream ID