mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-26 08:18:22 +00:00
tutorials: basic: fix missing markup
This commit is contained in:
parent
1ef0cd891a
commit
b0cb459527
|
@ -340,8 +340,8 @@ documentation or using the `gst-inspect-1.0` tool as described in [Basic
|
|||
tutorial 10: GStreamer
|
||||
tools](tutorials/basic/gstreamer-tools.md).
|
||||
|
||||
We are now ready to go! Just set the pipeline to the PLAYING state and
|
||||
start listening to the bus for interesting messages (like ERROR or EOS),
|
||||
We are now ready to go! Just set the pipeline to the `PLAYING` state and
|
||||
start listening to the bus for interesting messages (like `ERROR` or `EOS`),
|
||||
just like in the previous tutorials.
|
||||
|
||||
### The callback
|
||||
|
@ -446,20 +446,22 @@ from this tutorial by also introducing the concept of State.
|
|||
### GStreamer States
|
||||
|
||||
We already talked a bit about states when we said that playback does not
|
||||
start until you bring the pipeline to the PLAYING state. We will
|
||||
start until you bring the pipeline to the `PLAYING` state. We will
|
||||
introduce here the rest of states and their meaning. There are 4 states
|
||||
in GStreamer:
|
||||
|
||||
```
|
||||
| State | Description |
|
||||
|-----------|--------------------|
|
||||
| `NULL` | the NULL state or initial state of an element. |
|
||||
| `READY` | the element is ready to go to PAUSED. |
|
||||
| `PAUSED` | the element is PAUSED, it is ready to accept and process data. Sink elements however only accept one buffer and then block. |
|
||||
| `PLAYING` | the element is PLAYING, the clock is running and the data is flowing. |
|
||||
```
|
||||
|
||||
You can only move between adjacent ones, this is, you can't go from NULL
|
||||
to PLAYING, you have to go through the intermediate READY and PAUSED
|
||||
states. If you set the pipeline to PLAYING, though, GStreamer will make
|
||||
You can only move between adjacent ones, this is, you can't go from `NULL`
|
||||
to `PLAYING`, you have to go through the intermediate `READY` and `PAUSED`
|
||||
states. If you set the pipeline to `PLAYING`, though, GStreamer will make
|
||||
the intermediate transitions for you.
|
||||
|
||||
``` c
|
||||
|
@ -480,8 +482,8 @@ transitions. Every element puts messages on the bus regarding its
|
|||
current state, so we filter them out and only listen to messages coming
|
||||
from the pipeline.
|
||||
|
||||
Most applications only need to worry about going to PLAYING to start
|
||||
playback, then to PAUSE to perform a pause, and then back to NULL at
|
||||
Most applications only need to worry about going to `PLAYING` to start
|
||||
playback, then to `PAUSED` to perform a pause, and then back to `NULL` at
|
||||
program exit to free all resources.
|
||||
|
||||
## Exercise
|
||||
|
|
|
@ -141,10 +141,10 @@ This line highlights another interesting concept: the state. Every
|
|||
GStreamer element has an associated state, which you can more or less
|
||||
think of as the Play/Pause button in your regular DVD player. For now,
|
||||
suffice to say that playback will not start unless you set the pipeline
|
||||
to the PLAYING state.
|
||||
to the `PLAYING` state.
|
||||
|
||||
In this line, `gst_element_set_state()` is setting `pipeline` (our only
|
||||
element, remember) to the PLAYING state, thus initiating playback.
|
||||
element, remember) to the `PLAYING` state, thus initiating playback.
|
||||
|
||||
``` c
|
||||
/* Wait until error or EOS */
|
||||
|
@ -155,7 +155,7 @@ gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_ME
|
|||
These lines will wait until an error occurs or the end of the stream is
|
||||
found. `gst_element_get_bus()` retrieves the pipeline's bus, and
|
||||
`gst_bus_timed_pop_filtered()` will block until you receive either an
|
||||
ERROR or an EOS (End-Of-Stream) through that bus. Do not worry much
|
||||
ERROR or an `EOS` (End-Of-Stream) through that bus. Do not worry much
|
||||
about this line, the GStreamer bus is explained in [Basic tutorial 2:
|
||||
GStreamer concepts].
|
||||
|
||||
|
|
|
@ -70,10 +70,10 @@ number of times. The disadvantage is that linking elements with Request
|
|||
Pads is not as automatic, as linking Always Pads, as the walkthrough for
|
||||
this example will show.
|
||||
|
||||
Also, to request (or release) pads in the PLAYING or PAUSED states, you
|
||||
Also, to request (or release) pads in the `PLAYING` or `PAUSED` states, you
|
||||
need to take additional cautions (Pad blocking) which are not described
|
||||
in this tutorial. It is safe to request (or release) pads in the NULL or
|
||||
READY states, though.
|
||||
in this tutorial. It is safe to request (or release) pads in the `NULL` or
|
||||
`READY` states, though.
|
||||
|
||||
Without further delay, let's see the code.
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ the Event is sent to only one sink, in this case, the video sink. It is
|
|||
obtained from `playbin` through the `video-sink` property. It is read
|
||||
at this time instead at initialization time because the actual sink may
|
||||
change depending on the media contents, and this won’t be known until
|
||||
the pipeline is PLAYING and some media has been read.
|
||||
the pipeline is `PLAYING` and some media has been read.
|
||||
|
||||
``` c
|
||||
/* Send the event */
|
||||
|
@ -375,4 +375,4 @@ This tutorial has shown:
|
|||
- How to advance a video frame-by-frame by using Step Events, created
|
||||
with `gst_event_new_step()`.
|
||||
|
||||
It has been a pleasure having you here, and see you soon!
|
||||
It has been a pleasure having you here, and see you soon!
|
||||
|
|
|
@ -43,7 +43,7 @@ process is explained in this tutorial.
|
|||
|
||||
When the clock is lost, the application receives a message on the bus;
|
||||
to select a new one, the application just needs to set the pipeline to
|
||||
PAUSED and then to PLAYING again.
|
||||
`PAUSED` and then to `PLAYING` again.
|
||||
|
||||
## A network-resilient example
|
||||
|
||||
|
@ -185,13 +185,13 @@ if (ret == GST_STATE_CHANGE_FAILURE) {
|
|||
}
|
||||
```
|
||||
|
||||
Live streams cannot be paused, so they behave in PAUSED state as if they
|
||||
were in the PLAYING state. Setting live streams to PAUSED succeeds, but
|
||||
Live streams cannot be paused, so they behave in `PAUSED` state as if they
|
||||
were in the `PLAYING` state. Setting live streams to `PAUSED` succeeds, but
|
||||
returns `GST_STATE_CHANGE_NO_PREROLL`, instead of
|
||||
`GST_STATE_CHANGE_SUCCESS` to indicate that this is a live stream. We
|
||||
are receiving the NO\_PROROLL return code even though we are trying to
|
||||
set the pipeline to PLAYING, because state changes happen progressively
|
||||
(from NULL to READY, to PAUSED and then to PLAYING).
|
||||
are receiving the `NO_PREROLL` return code even though we are trying to
|
||||
set the pipeline to `PLAYING`, because state changes happen progressively
|
||||
(from NULL to READY, to `PAUSED` and then to `PLAYING`).
|
||||
|
||||
We care about live streams because we want to disable buffering for
|
||||
them, so we take note of the result of `gst_element_set_state()` in the
|
||||
|
@ -223,8 +223,8 @@ We parse the buffering message with `gst_message_parse_buffering()` to
|
|||
retrieve the buffering level.
|
||||
|
||||
Then, we print the buffering level on the console and set the pipeline
|
||||
to PAUSED if it is below 100%. Otherwise, we set the pipeline to
|
||||
PLAYING.
|
||||
to `PAUSED` if it is below 100%. Otherwise, we set the pipeline to
|
||||
`PLAYING`.
|
||||
|
||||
At startup, we will see the buffering level rise up to 100% before
|
||||
playback starts, which is what we wanted to achieve. If, later on, the
|
||||
|
@ -241,7 +241,7 @@ case GST_MESSAGE_CLOCK_LOST:
|
|||
```
|
||||
|
||||
For the second network issue, the loss of clock, we simply set the
|
||||
pipeline to PAUSED and back to PLAYING, so a new clock is selected,
|
||||
pipeline to `PAUSED` and back to `PLAYING`, so a new clock is selected,
|
||||
waiting for new media chunks to be received if necessary.
|
||||
|
||||
## Conclusion
|
||||
|
@ -255,4 +255,4 @@ application with two very simple precautions:
|
|||
Handling these messages improves the application’s response to network
|
||||
problems, increasing the overall playback smoothness.
|
||||
|
||||
It has been a pleasure having you here, and see you soon!
|
||||
It has been a pleasure having you here, and see you soon!
|
||||
|
|
|
@ -209,7 +209,7 @@ static void handle_message (CustomData *data, GstMessage *msg) {
|
|||
|
||||
## Walkthrough
|
||||
|
||||
```
|
||||
``` c
|
||||
/* Structure to contain all our information, so we can pass it around */
|
||||
typedef struct _CustomData {
|
||||
GstElement *playbin; /* Our one and only element */
|
||||
|
@ -237,7 +237,7 @@ element in the pipeline, so we use directly the `playbin` element. We
|
|||
will skip the details: the URI of the clip is given to `playbin` via
|
||||
the URI property and the pipeline is set to the playing state.
|
||||
|
||||
```
|
||||
``` c
|
||||
msg = gst_bus_timed_pop_filtered (bus, 100 * GST_MSECOND,
|
||||
GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS | GST_MESSAGE_DURATION);
|
||||
```
|
||||
|
@ -256,12 +256,12 @@ If we got a message, we process it in the `handle_message`` `function
|
|||
|
||||
### User interface resfreshing
|
||||
|
||||
```
|
||||
``` c
|
||||
/* We got no message, this means the timeout expired */
|
||||
if (data.playing) {
|
||||
```
|
||||
|
||||
First off, if we are not in the PLAYING state, we do not want to do
|
||||
First off, if we are not in the `PLAYING` state, we do not want to do
|
||||
anything here, since most queries would fail. Otherwise, it is time to
|
||||
refresh the screen.
|
||||
|
||||
|
@ -272,7 +272,7 @@ few steps that will be shown in the next subsection, but, since position
|
|||
and duration are common enough queries, `GstElement` offers easier,
|
||||
ready-made alternatives:
|
||||
|
||||
```
|
||||
``` c
|
||||
/* Query the current position of the stream */
|
||||
if (!gst_element_query_position (data.pipeline, GST_FORMAT_TIME, ¤t)) {
|
||||
g_printerr ("Could not query current position.\n");
|
||||
|
@ -282,7 +282,7 @@ if (!gst_element_query_position (data.pipeline, GST_FORMAT_TIME, ¤t)) {
|
|||
`gst_element_query_position()` hides the management of the query object
|
||||
and directly provides us with the result.
|
||||
|
||||
```
|
||||
``` c
|
||||
/* If we didn't know it yet, query the stream duration */
|
||||
if (!GST_CLOCK_TIME_IS_VALID (data.duration)) {
|
||||
if (!gst_element_query_duration (data.pipeline, GST_FORMAT_TIME, &data.duration)) {
|
||||
|
@ -294,7 +294,7 @@ if (!GST_CLOCK_TIME_IS_VALID (data.duration)) {
|
|||
Now is a good moment to know the length of the stream, with
|
||||
another `GstElement` helper function: `gst_element_query_duration()`
|
||||
|
||||
```
|
||||
``` c
|
||||
/* Print current position and total duration */
|
||||
g_print ("Position %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\r",
|
||||
GST_TIME_ARGS (current), GST_TIME_ARGS (data.duration));
|
||||
|
@ -304,7 +304,7 @@ Note the usage of the `GST_TIME_FORMAT` and `GST_TIME_ARGS` macros to
|
|||
provide user-friendly representation of GStreamer
|
||||
times.
|
||||
|
||||
```
|
||||
``` c
|
||||
/* If seeking is enabled, we have not done it yet, and the time is right, seek */
|
||||
if (data.seek_enabled && !data.seek_done && current > 10 * GST_SECOND) {
|
||||
g_print ("\nReached 10s, performing seek...\n");
|
||||
|
@ -360,7 +360,7 @@ The `handle_message` function processes all messages received through
|
|||
the pipeline's bus. ERROR and EOS handling is the same as in previous
|
||||
tutorials, so we skip to the interesting part:
|
||||
|
||||
```
|
||||
``` c
|
||||
case GST_MESSAGE_DURATION:
|
||||
/* The duration has changed, mark the current one as invalid */
|
||||
data->duration = GST_CLOCK_TIME_NONE;
|
||||
|
@ -371,7 +371,7 @@ This message is posted on the bus whenever the duration of the stream
|
|||
changes. Here we simply mark the current duration as invalid, so it gets
|
||||
re-queried later.
|
||||
|
||||
```
|
||||
``` c
|
||||
case GST_MESSAGE_STATE_CHANGED: {
|
||||
GstState old_state, new_state, pending_state;
|
||||
gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);
|
||||
|
@ -392,7 +392,7 @@ variable.
|
|||
Also, if we have just entered the PLAYING state, we do our first query.
|
||||
We ask the pipeline if seeking is allowed on this stream:
|
||||
|
||||
```
|
||||
``` c
|
||||
if (data->playing) {
|
||||
/* We just moved to PLAYING. Check if seeking is possible */
|
||||
GstQuery *query;
|
||||
|
|
|
@ -667,7 +667,7 @@ static void delete_event_cb (GtkWidget *widget, GdkEvent *event, CustomData *dat
|
|||
}
|
||||
```
|
||||
|
||||
gtk_main_quit() will eventually make the call to to gtk_main_run()
|
||||
`gtk_main_quit()` will eventually make the call to to `gtk_main_run()`
|
||||
in `main` to terminate, which, in this case, finishes the program. Here,
|
||||
we call it when the main window is closed, after stopping the pipeline
|
||||
(just for the sake of tidiness).
|
||||
|
@ -778,8 +778,8 @@ requested them, we disable the `value-changed` signal emission during
|
|||
this operation with `g_signal_handler_block()` and
|
||||
`g_signal_handler_unblock()`.
|
||||
|
||||
Returning TRUE from this function will keep it called in the future. If
|
||||
we return FALSE, the timer will be
|
||||
Returning `TRUE` from this function will keep it called in the future. If
|
||||
we return `FALSE`, the timer will be
|
||||
removed.
|
||||
|
||||
``` c
|
||||
|
|
Loading…
Reference in a new issue