GstPlayer: make it build and add simple example

This commit is contained in:
Philippe Normand 2017-08-07 15:35:57 +01:00 committed by Sebastian Dröge
parent 8badc33df9
commit 1e12354cd5
26 changed files with 1615 additions and 630 deletions

31
Cargo.lock generated
View file

@ -112,6 +112,7 @@ dependencies = [
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"gstreamer 0.1.0",
"gstreamer-app 0.1.0",
"gstreamer-player 0.1.0",
"gtk 0.1.3 (git+https://github.com/gtk-rs/gtk)",
"send-cell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -327,6 +328,35 @@ dependencies = [
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gstreamer-player"
version = "0.1.0"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gstreamer 0.1.0",
"gstreamer-player-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)",
"gstreamer-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)",
"libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"rustdoc-stripper 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gstreamer-player-sys"
version = "0.1.1"
source = "git+https://github.com/sdroege/gstreamer-sys#669b24f66122067891bb5548e3ef85bc63493c19"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glib-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gobject-sys 0.3.4 (git+https://github.com/gtk-rs/sys)",
"gstreamer-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)",
"gstreamer-video-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)",
"libc 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gstreamer-sys"
version = "0.1.1"
@ -658,6 +688,7 @@ dependencies = [
"checksum gstreamer-app-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gstreamer-audio-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gstreamer-base-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gstreamer-player-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gstreamer-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gstreamer-tag-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"
"checksum gstreamer-video-sys 0.1.1 (git+https://github.com/sdroege/gstreamer-sys)" = "<none>"

View file

@ -4,6 +4,7 @@ members = [
"gstreamer",
"gstreamer-app",
"gstreamer-audio",
"gstreamer-player",
"gstreamer-video",
"examples",
]

View file

@ -2,7 +2,7 @@
girs_dir = "gir-files"
library = "GstPlayer"
version = "1.0"
min_cfg_version = "1.10"
min_cfg_version = "1.12"
target_path = "gstreamer-player"
work_mode = "normal"
concurrency = "send+sync"
@ -14,7 +14,6 @@ external_libraries = [
]
generate = [
"GstPlayer.Player",
"GstPlayer.PlayerAudioInfo",
"GstPlayer.PlayerColorBalanceType",
"GstPlayer.PlayerError",
@ -36,7 +35,6 @@ manual = [
"GLib.MainContext",
"GObject.Object",
"Gst.ClockTime",
"Gst.Structure",
"Gst.Element",
]
@ -54,3 +52,81 @@ ref_mode = "ref"
name = "Gst.Sample"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Structure"
status = "manual"
ref_mode = "ref-mut"
[[object]]
name = "GstPlayer.Player"
status = "generate"
trait = false
[[object.function]]
name = "visualizations_free"
# correct mutability
ignore = true
[[object.function]]
name = "set_config"
# Pass by value
ignore = true
[[object.function]]
name = "new"
ignore = true
[[object.signal]]
name = "buffering"
concurrency = "send"
[[object.signal]]
name = "duration-changed"
concurrency = "send"
[[object.signal]]
name = "end-of-stream"
concurrency = "send"
[[object.signal]]
name = "error"
concurrency = "send"
[[object.signal]]
name = "media-info-updated"
concurrency = "send"
[[object.signal]]
name = "mute-changed"
concurrency = "send"
[[object.signal]]
name = "position-changed"
concurrency = "send"
[[object.signal]]
name = "seek-done"
concurrency = "send"
[[object.signal]]
name = "state-changed"
concurrency = "send"
[[object.signal]]
name = "uri-loaded"
concurrency = "send"
[[object.signal]]
name = "video-dimensions-changed"
concurrency = "send"
[[object.signal]]
name = "volume-changed"
concurrency = "send"
[[object.signal]]
name = "warning"
concurrency = "send"

View file

@ -0,0 +1,794 @@
<!-- file * -->
<!-- struct Player -->
# Implements
[`ObjectExt`](trait.ObjectExt.html)
<!-- impl Player::fn new -->
Creates a new `Player` instance that uses `signal_dispatcher` to dispatch
signals to some event loop system, or emits signals directly if NULL is
passed. See `PlayerGMainContextSignalDispatcher::new`.
Video is going to be rendered by `video_renderer`, or if `None` is provided
no special video set up will be done and some default handling will be
performed.
## `video_renderer`
GstPlayerVideoRenderer to use
## `signal_dispatcher`
GstPlayerSignalDispatcher to use
# Returns
a new `Player` instance
<!-- impl Player::fn config_get_position_update_interval -->
## `config`
a `Player` configuration
# Returns
current position update interval in milliseconds
Since 1.10
<!-- impl Player::fn config_get_seek_accurate -->
## `config`
a `Player` configuration
# Returns
`true` if accurate seeking is enabled
Since 1.12
<!-- impl Player::fn config_get_user_agent -->
Return the user agent which has been configured using
`Player::config_set_user_agent` if any.
## `config`
a `Player` configuration
# Returns
the configured agent, or `None`
Since 1.10
<!-- impl Player::fn config_set_position_update_interval -->
set interval in milliseconds between two position-updated signals.
pass 0 to stop updating the position.
Since 1.10
## `config`
a `Player` configuration
## `interval`
interval in ms
<!-- impl Player::fn config_set_user_agent -->
Set the user agent to pass to the server if `player` needs to connect
to a server during playback. This is typically used when playing HTTP
or RTSP streams.
Since 1.10
## `config`
a `Player` configuration
## `agent`
the string to use as user agent
<!-- impl Player::fn get_audio_streams -->
## `info`
a `PlayerMediaInfo`
# Returns
A `glib::List` of
matching `PlayerAudioInfo`.
<!-- impl Player::fn get_subtitle_streams -->
## `info`
a `PlayerMediaInfo`
# Returns
A `glib::List` of
matching `PlayerSubtitleInfo`.
<!-- impl Player::fn get_video_streams -->
## `info`
a `PlayerMediaInfo`
# Returns
A `glib::List` of
matching `PlayerVideoInfo`.
<!-- impl Player::fn visualizations_free -->
Frees a `None` terminated array of `PlayerVisualization`.
## `viss`
a `None` terminated array of `PlayerVisualization` to free
<!-- impl Player::fn visualizations_get -->
# Returns
a `None` terminated array containing all available
visualizations. Use `Player::visualizations_free` after
usage.
<!-- impl Player::fn config_set_seek_accurate -->
Enable or disable accurate seeking. When enabled, elements will try harder
to seek as accurately as possible to the requested seek position. Generally
it will be slower especially for formats that don't have any indexes or
timestamp markers in the stream.
If accurate seeking is disabled, elements will seek as close as the request
position without slowing down seeking too much.
Accurate seeking is disabled by default.
Feature: `v1_12`
## `accurate`
accurate seek or not
<!-- impl Player::fn get_audio_video_offset -->
Retrieve the current value of audio-video-offset property
# Returns
The current value of audio-video-offset in nanoseconds
Since 1.10
<!-- impl Player::fn get_color_balance -->
Retrieve the current value of the indicated `type_`.
## `type_`
`PlayerColorBalanceType`
# Returns
The current value of `type_`, between [0,1]. In case of
error -1 is returned.
<!-- impl Player::fn get_config -->
Get a copy of the current configuration of the player. This configuration
can either be modified and used for the `Player::set_config` call
or it must be freed after usage.
# Returns
a copy of the current configuration of `self`. Use
`gst::Structure::free` after usage or `Player::set_config`.
Since 1.10
<!-- impl Player::fn get_current_audio_track -->
A Function to get current audio `PlayerAudioInfo` instance.
# Returns
current audio track.
The caller should free it with `gobject::ObjectExt::unref`
<!-- impl Player::fn get_current_subtitle_track -->
A Function to get current subtitle `PlayerSubtitleInfo` instance.
# Returns
current subtitle track.
The caller should free it with `gobject::ObjectExt::unref`
<!-- impl Player::fn get_current_video_track -->
A Function to get current video `PlayerVideoInfo` instance.
# Returns
current video track.
The caller should free it with `gobject::ObjectExt::unref`
<!-- impl Player::fn get_current_visualization -->
# Returns
Name of the currently enabled visualization.
`g_free` after usage.
<!-- impl Player::fn get_duration -->
Retrieves the duration of the media stream that self represents.
# Returns
the duration of the currently-playing media stream, in
nanoseconds.
<!-- impl Player::fn get_media_info -->
A Function to get the current media info `PlayerMediaInfo` instance.
# Returns
media info instance.
The caller should free it with `gobject::ObjectExt::unref`
<!-- impl Player::fn get_multiview_flags -->
Retrieve the current value of the indicated `type_`.
# Returns
The current value of `type_`, Default: 0x00000000 "none
<!-- impl Player::fn get_multiview_mode -->
Retrieve the current value of the indicated `type_`.
# Returns
The current value of `type_`, Default: -1 "none"
<!-- impl Player::fn get_mute -->
# Returns
`true` if the currently-playing stream is muted.
<!-- impl Player::fn get_pipeline -->
# Returns
The internal playbin instance
<!-- impl Player::fn get_position -->
# Returns
the absolute position time, in nanoseconds, of the
currently-playing stream.
<!-- impl Player::fn get_rate -->
# Returns
current playback rate
<!-- impl Player::fn get_subtitle_uri -->
current subtitle URI
# Returns
URI of the current external subtitle.
`g_free` after usage.
<!-- impl Player::fn get_uri -->
Gets the URI of the currently-playing stream.
# Returns
a string containing the URI of the
currently-playing stream. `g_free` after usage.
<!-- impl Player::fn get_video_snapshot -->
Get a snapshot of the currently selected video stream, if any. The format can be
selected with `format` and optional configuration is possible with `config`
Currently supported settings are:
- width, height of type G_TYPE_INT
- pixel-aspect-ratio of type GST_TYPE_FRACTION
Except for GST_PLAYER_THUMBNAIL_RAW_NATIVE format, if no config is set, pixel-aspect-ratio would be 1/1
## `format`
output format of the video snapshot
## `config`
Additional configuration
# Returns
Current video snapshot sample or `None` on failure
Since 1.12
<!-- impl Player::fn get_volume -->
Returns the current volume level, as a percentage between 0 and 1.
# Returns
the volume as percentage between 0 and 1.
<!-- impl Player::fn has_color_balance -->
Checks whether the `self` has color balance support available.
# Returns
`true` if `self` has color balance support. Otherwise,
`false`.
<!-- impl Player::fn pause -->
Pauses the current stream.
<!-- impl Player::fn play -->
Request to play the loaded stream.
<!-- impl Player::fn seek -->
Seeks the currently-playing stream to the absolute `position` time
in nanoseconds.
## `position`
position to seek in nanoseconds
<!-- impl Player::fn set_audio_track -->
## `stream_index`
stream index
# Returns
`true` or `false`
Sets the audio track `stream_idex`.
<!-- impl Player::fn set_audio_track_enabled -->
Enable or disable the current audio track.
## `enabled`
TRUE or FALSE
<!-- impl Player::fn set_audio_video_offset -->
Sets audio-video-offset property by value of `offset`
Since 1.10
## `offset`
`gint64` in nanoseconds
<!-- impl Player::fn set_color_balance -->
Sets the current value of the indicated channel `type_` to the passed
value.
## `type_`
`PlayerColorBalanceType`
## `value`
The new value for the `type_`, ranged [0,1]
<!-- impl Player::fn set_config -->
Set the configuration of the player. If the player is already configured, and
the configuration haven't change, this function will return `true`. If the
player is not in the GST_PLAYER_STATE_STOPPED, this method will return `false`
and active configuration will remain.
`config` is a `gst::Structure` that contains the configuration parameters for
the player.
This function takes ownership of `config`.
## `config`
a `gst::Structure`
# Returns
`true` when the configuration could be set.
Since 1.10
<!-- impl Player::fn set_multiview_flags -->
Sets the current value of the indicated mode `type_` to the passed
value.
## `flags`
The new value for the `type_`
<!-- impl Player::fn set_multiview_mode -->
Sets the current value of the indicated mode `type_` to the passed
value.
## `mode`
The new value for the `type_`
<!-- impl Player::fn set_mute -->
`true` if the currently-playing stream should be muted.
## `val`
Mute state the should be set
<!-- impl Player::fn set_rate -->
Playback at specified rate
## `rate`
playback rate
<!-- impl Player::fn set_subtitle_track -->
## `stream_index`
stream index
# Returns
`true` or `false`
Sets the subtitle strack `stream_index`.
<!-- impl Player::fn set_subtitle_track_enabled -->
Enable or disable the current subtitle track.
## `enabled`
TRUE or FALSE
<!-- impl Player::fn set_subtitle_uri -->
Sets the external subtitle URI.
## `uri`
subtitle URI
<!-- impl Player::fn set_uri -->
Sets the next URI to play.
## `uri`
next URI to play.
<!-- impl Player::fn set_video_track -->
## `stream_index`
stream index
# Returns
`true` or `false`
Sets the video track `stream_index`.
<!-- impl Player::fn set_video_track_enabled -->
Enable or disable the current video track.
## `enabled`
TRUE or FALSE
<!-- impl Player::fn set_visualization -->
## `name`
visualization element obtained from
`Player::visualizations_get`()
# Returns
`true` if the visualizations was set correctly. Otherwise,
`false`.
<!-- impl Player::fn set_visualization_enabled -->
Enable or disable the visualization.
## `enabled`
TRUE or FALSE
<!-- impl Player::fn set_volume -->
Sets the volume level of the stream as a percentage between 0 and 1.
## `val`
the new volume level, as a percentage between 0 and 1
<!-- impl Player::fn stop -->
Stops playing the current stream and resets to the first position
in the stream.
<!-- struct PlayerAudioInfo -->
`PlayerStreamInfo` specific to audio streams.
# Implements
[`PlayerAudioInfoExt`](trait.PlayerAudioInfoExt.html), [`PlayerStreamInfoExt`](trait.PlayerStreamInfoExt.html), [`ObjectExt`](trait.ObjectExt.html)
<!-- trait PlayerAudioInfoExt -->
Trait containing all `PlayerAudioInfo` methods.
# Implementors
[`PlayerAudioInfo`](struct.PlayerAudioInfo.html)
<!-- trait PlayerAudioInfoExt::fn get_bitrate -->
# Returns
the audio bitrate in `PlayerAudioInfo`.
<!-- trait PlayerAudioInfoExt::fn get_channels -->
# Returns
the number of audio channels in `PlayerAudioInfo`.
<!-- trait PlayerAudioInfoExt::fn get_language -->
# Returns
the language of the stream, or NULL if unknown.
<!-- trait PlayerAudioInfoExt::fn get_max_bitrate -->
# Returns
the audio maximum bitrate in `PlayerAudioInfo`.
<!-- trait PlayerAudioInfoExt::fn get_sample_rate -->
# Returns
the audio sample rate in `PlayerAudioInfo`.
<!-- enum PlayerColorBalanceType -->
<!-- enum PlayerColorBalanceType::variant Hue -->
hue or color balance.
<!-- enum PlayerColorBalanceType::variant Brightness -->
brightness or black level.
<!-- enum PlayerColorBalanceType::variant Saturation -->
color saturation or chroma
gain.
<!-- enum PlayerColorBalanceType::variant Contrast -->
contrast or luma gain.
<!-- enum PlayerError -->
<!-- enum PlayerError::variant Failed -->
generic error.
<!-- struct PlayerGMainContextSignalDispatcher -->
# Implements
[`PlayerGMainContextSignalDispatcherExt`](trait.PlayerGMainContextSignalDispatcherExt.html), [`ObjectExt`](trait.ObjectExt.html), [`PlayerSignalDispatcherExt`](trait.PlayerSignalDispatcherExt.html)
<!-- trait PlayerGMainContextSignalDispatcherExt -->
Trait containing all `PlayerGMainContextSignalDispatcher` methods.
# Implementors
[`PlayerGMainContextSignalDispatcher`](struct.PlayerGMainContextSignalDispatcher.html)
<!-- impl PlayerGMainContextSignalDispatcher::fn new -->
Creates a new GstPlayerSignalDispatcher that uses `application_context`,
or the thread default one if `None` is used. See `gst_player_new_full`.
## `application_context`
GMainContext to use or `None`
# Returns
the new GstPlayerSignalDispatcher
<!-- struct PlayerMediaInfo -->
Structure containing the media information of a URI.
# Implements
[`PlayerMediaInfoExt`](trait.PlayerMediaInfoExt.html), [`ObjectExt`](trait.ObjectExt.html)
<!-- trait PlayerMediaInfoExt -->
Trait containing all `PlayerMediaInfo` methods.
# Implementors
[`PlayerMediaInfo`](struct.PlayerMediaInfo.html)
<!-- trait PlayerMediaInfoExt::fn get_audio_streams -->
# Returns
A `glib::List` of
matching `PlayerAudioInfo`.
<!-- trait PlayerMediaInfoExt::fn get_container_format -->
# Returns
the container format.
<!-- trait PlayerMediaInfoExt::fn get_duration -->
# Returns
duration of the media.
<!-- trait PlayerMediaInfoExt::fn get_image_sample -->
Function to get the image (or preview-image) stored in taglist.
Application can use gst_sample_*`_` API's to get caps, buffer etc.
# Returns
GstSample or NULL.
<!-- trait PlayerMediaInfoExt::fn get_number_of_audio_streams -->
Feature: `v1_12`
# Returns
number of audio streams.
<!-- trait PlayerMediaInfoExt::fn get_number_of_streams -->
Feature: `v1_12`
# Returns
number of total streams.
<!-- trait PlayerMediaInfoExt::fn get_number_of_subtitle_streams -->
Feature: `v1_12`
# Returns
number of subtitle streams.
<!-- trait PlayerMediaInfoExt::fn get_number_of_video_streams -->
Feature: `v1_12`
# Returns
number of video streams.
<!-- trait PlayerMediaInfoExt::fn get_stream_list -->
# Returns
A `glib::List` of
matching `PlayerStreamInfo`.
<!-- trait PlayerMediaInfoExt::fn get_subtitle_streams -->
# Returns
A `glib::List` of
matching `PlayerSubtitleInfo`.
<!-- trait PlayerMediaInfoExt::fn get_tags -->
# Returns
the tags contained in media info.
<!-- trait PlayerMediaInfoExt::fn get_title -->
# Returns
the media title.
<!-- trait PlayerMediaInfoExt::fn get_uri -->
# Returns
the URI associated with `PlayerMediaInfo`.
<!-- trait PlayerMediaInfoExt::fn get_video_streams -->
# Returns
A `glib::List` of
matching `PlayerVideoInfo`.
<!-- trait PlayerMediaInfoExt::fn is_live -->
# Returns
`true` if the media is live.
<!-- trait PlayerMediaInfoExt::fn is_seekable -->
# Returns
`true` if the media is seekable.
<!-- struct PlayerSignalDispatcher -->
# Implements
[`PlayerSignalDispatcherExt`](trait.PlayerSignalDispatcherExt.html)
<!-- trait PlayerSignalDispatcherExt -->
Trait containing all `PlayerSignalDispatcher` methods.
# Implementors
[`PlayerGMainContextSignalDispatcher`](struct.PlayerGMainContextSignalDispatcher.html), [`PlayerSignalDispatcher`](struct.PlayerSignalDispatcher.html)
<!-- enum PlayerSnapshotFormat -->
<!-- enum PlayerState -->
<!-- enum PlayerState::variant Stopped -->
the player is stopped.
<!-- enum PlayerState::variant Buffering -->
the player is buffering.
<!-- enum PlayerState::variant Paused -->
the player is paused.
<!-- enum PlayerState::variant Playing -->
the player is currently playing a
stream.
<!-- struct PlayerStreamInfo -->
Base structure for information concering a media stream. Depending on
the stream type, one can find more media-specific information in
`PlayerVideoInfo`, `PlayerAudioInfo`, `PlayerSubtitleInfo`.
# Implements
[`PlayerStreamInfoExt`](trait.PlayerStreamInfoExt.html), [`ObjectExt`](trait.ObjectExt.html)
<!-- trait PlayerStreamInfoExt -->
Trait containing all `PlayerStreamInfo` methods.
# Implementors
[`PlayerAudioInfo`](struct.PlayerAudioInfo.html), [`PlayerStreamInfo`](struct.PlayerStreamInfo.html), [`PlayerSubtitleInfo`](struct.PlayerSubtitleInfo.html), [`PlayerVideoInfo`](struct.PlayerVideoInfo.html)
<!-- trait PlayerStreamInfoExt::fn get_caps -->
# Returns
the `gst::Caps` of the stream.
<!-- trait PlayerStreamInfoExt::fn get_codec -->
A string describing codec used in `PlayerStreamInfo`.
# Returns
codec string or NULL on unknown.
<!-- trait PlayerStreamInfoExt::fn get_index -->
Function to get stream index from `PlayerStreamInfo` instance.
# Returns
the stream index of this stream.
<!-- trait PlayerStreamInfoExt::fn get_stream_type -->
Function to return human readable name for the stream type
of the given `self` (ex: "audio", "video", "subtitle")
# Returns
a human readable name
<!-- trait PlayerStreamInfoExt::fn get_tags -->
# Returns
the tags contained in this stream.
<!-- struct PlayerSubtitleInfo -->
`PlayerStreamInfo` specific to subtitle streams.
# Implements
[`PlayerSubtitleInfoExt`](trait.PlayerSubtitleInfoExt.html), [`PlayerStreamInfoExt`](trait.PlayerStreamInfoExt.html), [`ObjectExt`](trait.ObjectExt.html)
<!-- trait PlayerSubtitleInfoExt -->
Trait containing all `PlayerSubtitleInfo` methods.
# Implementors
[`PlayerSubtitleInfo`](struct.PlayerSubtitleInfo.html)
<!-- trait PlayerSubtitleInfoExt::fn get_language -->
# Returns
the language of the stream, or NULL if unknown.
<!-- struct PlayerVideoInfo -->
`PlayerStreamInfo` specific to video streams.
# Implements
[`PlayerVideoInfoExt`](trait.PlayerVideoInfoExt.html), [`PlayerStreamInfoExt`](trait.PlayerStreamInfoExt.html), [`ObjectExt`](trait.ObjectExt.html)
<!-- trait PlayerVideoInfoExt -->
Trait containing all `PlayerVideoInfo` methods.
# Implementors
[`PlayerVideoInfo`](struct.PlayerVideoInfo.html)
<!-- trait PlayerVideoInfoExt::fn get_bitrate -->
# Returns
the current bitrate of video in `PlayerVideoInfo`.
<!-- trait PlayerVideoInfoExt::fn get_framerate -->
## `fps_n`
Numerator of frame rate
## `fps_d`
Denominator of frame rate
<!-- trait PlayerVideoInfoExt::fn get_height -->
# Returns
the height of video in `PlayerVideoInfo`.
<!-- trait PlayerVideoInfoExt::fn get_max_bitrate -->
# Returns
the maximum bitrate of video in `PlayerVideoInfo`.
<!-- trait PlayerVideoInfoExt::fn get_pixel_aspect_ratio -->
Returns the pixel aspect ratio in `par_n` and `par_d`
## `par_n`
numerator
## `par_d`
denominator
<!-- trait PlayerVideoInfoExt::fn get_width -->
# Returns
the width of video in `PlayerVideoInfo`.
<!-- struct PlayerVideoOverlayVideoRenderer -->
# Implements
[`PlayerVideoOverlayVideoRendererExt`](trait.PlayerVideoOverlayVideoRendererExt.html), [`ObjectExt`](trait.ObjectExt.html), [`PlayerVideoRendererExt`](trait.PlayerVideoRendererExt.html)
<!-- trait PlayerVideoOverlayVideoRendererExt -->
Trait containing all `PlayerVideoOverlayVideoRenderer` methods.
# Implementors
[`PlayerVideoOverlayVideoRenderer`](struct.PlayerVideoOverlayVideoRenderer.html)
<!-- impl PlayerVideoOverlayVideoRenderer::fn new -->
## `window_handle`
Window handle to use or `None`
<!-- impl PlayerVideoOverlayVideoRenderer::fn new_with_sink -->
## `window_handle`
Window handle to use or `None`
## `video_sink`
the custom video_sink element to be set for the video renderer
# Returns
Since 1.12
<!-- trait PlayerVideoOverlayVideoRendererExt::fn expose -->
Tell an overlay that it has been exposed. This will redraw the current frame
in the drawable even if the pipeline is PAUSED.
<!-- trait PlayerVideoOverlayVideoRendererExt::fn get_render_rectangle -->
Return the currently configured render rectangle. See `PlayerVideoOverlayVideoRendererExt::set_render_rectangle`
for details.
## `x`
the horizontal offset of the render area inside the window
## `y`
the vertical offset of the render area inside the window
## `width`
the width of the render area inside the window
## `height`
the height of the render area inside the window
<!-- trait PlayerVideoOverlayVideoRendererExt::fn get_window_handle -->
# Returns
The currently set, platform specific window
handle
<!-- trait PlayerVideoOverlayVideoRendererExt::fn set_render_rectangle -->
Configure a subregion as a video target within the window set by
`PlayerVideoOverlayVideoRendererExt::set_window_handle`. If this is not
used or not supported the video will fill the area of the window set as the
overlay to 100%. By specifying the rectangle, the video can be overlaid to
a specific region of that window only. After setting the new rectangle one
should call `PlayerVideoOverlayVideoRendererExt::expose` to force a
redraw. To unset the region pass -1 for the `width` and `height` parameters.
This method is needed for non fullscreen video overlay in UI toolkits that
do not support subwindows.
## `x`
the horizontal offset of the render area inside the window
## `y`
the vertical offset of the render area inside the window
## `width`
the width of the render area inside the window
## `height`
the height of the render area inside the window
<!-- trait PlayerVideoOverlayVideoRendererExt::fn set_window_handle -->
Sets the platform specific window handle into which the video
should be rendered
## `window_handle`
handle referencing to the platform specific window
<!-- struct PlayerVideoRenderer -->
# Implements
[`PlayerVideoRendererExt`](trait.PlayerVideoRendererExt.html)
<!-- trait PlayerVideoRendererExt -->
Trait containing all `PlayerVideoRenderer` methods.
# Implementors
[`PlayerVideoOverlayVideoRenderer`](struct.PlayerVideoOverlayVideoRenderer.html), [`PlayerVideoRenderer`](struct.PlayerVideoRenderer.html)
<!-- struct PlayerVisualization -->
A `PlayerVisualization` descriptor.
<!-- impl PlayerVisualization::fn copy -->
Makes a copy of the `PlayerVisualization`. The result must be
freed using `PlayerVisualization::free`.
# Returns
an allocated copy of `self`.
<!-- impl PlayerVisualization::fn free -->
Frees a `PlayerVisualization`.

View file

@ -7,8 +7,13 @@ authors = ["Sebastian Dröge <sebastian@centricular.com>"]
glib = { version = "0.1.3", git = "https://github.com/gtk-rs/glib" }
gstreamer = { path = "../gstreamer" }
gstreamer-app = { path = "../gstreamer-app" }
gstreamer-player = { path = "../gstreamer-player", optional = true }
gtk = { version = "0.1.3", git = "https://github.com/gtk-rs/gtk", features = ["v3_6"] }
gio = { version = "0.1.3", git = "https://github.com/gtk-rs/gio" }
futures = "0.1"
tokio-core = "0.1"
send-cell = "0.1"
[features]
gst-player = ["gstreamer-player"]
default-features = []

View file

@ -0,0 +1,96 @@
extern crate gstreamer as gst;
#[cfg(feature = "gst-player")]
extern crate gstreamer_player as gst_player;
extern crate glib;
#[allow(unused_imports)]
use glib::ObjectExt;
extern crate send_cell;
use std::env;
pub mod utils;
#[cfg(feature = "gst-player")]
fn main_loop(uri: &str) -> Result<(), utils::ExampleError> {
gst::init().map_err(utils::ExampleError::InitFailed)?;
let main_loop = glib::MainLoop::new(None, false);
let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None).unwrap();
let player = gst_player::Player::new(None, Some(&dispatcher));
player
.set_property("uri", &glib::Value::from(uri))
.expect("Can't set uri property");
let result = std::cell::RefCell::new(Some(Ok(())));
let error = std::sync::Arc::new(std::sync::Mutex::new(send_cell::SendCell::new(result)));
let error_clone = error.clone();
let player_clone = player.clone();
let main_loop_clone = main_loop.clone();
player.connect_end_of_stream(move |_| {
let main_loop = &main_loop_clone;
let player = &player_clone;
player.stop();
main_loop.quit();
});
let player_clone = player.clone();
let main_loop_clone = main_loop.clone();
player.connect_error(move |_, err| {
let main_loop = &main_loop_clone;
let player = &player_clone;
let error = std::sync::Arc::clone(&error_clone);
let guard = error.lock().unwrap();
let cell = &*guard;
let refcell = cell.get();
*refcell.borrow_mut() = Some(Err(utils::ExampleError::ElementError(
"player".to_owned(),
err.clone(),
"".to_owned(),
)));
player.stop();
main_loop.quit();
});
player.play();
main_loop.run();
let guard = error.as_ref().lock().unwrap();
let cell = &*guard;
let refcell = cell.get();
let result = refcell.borrow();
if let Some(ref e) = *result {
return e.clone();
} else {
Ok(())
}
}
#[cfg(not(feature = "gst-player"))]
#[allow(unused_variables)]
fn main_loop(uri: &str) -> Result<(), utils::ExampleError> {
Err(utils::ExampleError::MissingFeature("gst-player"))
}
fn main() {
let args: Vec<_> = env::args().collect();
let uri: &str = if args.len() == 2 {
args[1].as_ref()
} else {
panic!("Usage: player uri");
};
match main_loop(uri) {
Ok(r) => r,
Err(e) => eprintln!("Error! {}", e),
}
}

View file

@ -5,13 +5,14 @@ use gst::*;
extern crate glib;
use std::fmt;
#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum ExampleError {
InitFailed(glib::Error),
ElementNotFound(&'static str),
ElementLinkFailed(::std::string::String, ::std::string::String),
SetStateError(::std::string::String),
ElementError(::std::string::String, glib::Error, ::std::string::String),
MissingFeature(&'static str),
}
impl fmt::Display for ExampleError {
@ -30,6 +31,12 @@ impl fmt::Display for ExampleError {
ExampleError::ElementError(ref element, ref err, ref debug) => {
write!(f, "Error from {}: {} ({:?})", element, err, debug)
}
ExampleError::MissingFeature(ref feature) => write!(
f,
"Feature {} is required. Please rebuild with --features {}",
feature,
feature
),
}
}
}

View file

@ -25,8 +25,8 @@ version = "0.1"
optional = true
[features]
v1_10 = ["gstreamer-sys/v1_10"]
v1_12 = ["gstreamer-sys/v1_12", "v1_10"]
v1_10 = ["gstreamer-sys/v1_10", "gstreamer-app-sys/v1_10"]
v1_12 = ["gstreamer-sys/v1_12", "gstreamer-app-sys/v1_12", "v1_10"]
embed-lgpl-docs = ["rustdoc-stripper"]
purge-lgpl-docs = ["rustdoc-stripper"]
default-features = []

View file

@ -0,0 +1,30 @@
[package]
name = "gstreamer-player"
version = "0.1.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
categories = ["api-bindings", "multimedia"]
description = "Rust bindings for GStreamer Player library"
repository = "https://github.com/sdroege/gstreamer-rs"
license = "MIT/Apache-2.0"
documentation = "https://gstreamer.freedesktop.org"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs"
[dependencies]
bitflags = "0.9"
libc = "0.2"
glib-sys = { version = "0.3.4", git = "https://github.com/gtk-rs/sys" }
gobject-sys = { version = "0.3.4", git = "https://github.com/gtk-rs/sys" }
gstreamer-sys = { version = "0.1.1", git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_12"] }
gstreamer-player-sys = { version = "0.1.1", git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_12"] }
glib = { version = "0.1.3", git = "https://github.com/gtk-rs/glib" }
gstreamer = { version = "0.1.0", path = "../gstreamer", features = ["v1_12"] }
[build-dependencies.rustdoc-stripper]
version = "0.1"
optional = true
[features]
embed-lgpl-docs = ["rustdoc-stripper"]
purge-lgpl-docs = ["rustdoc-stripper"]
default-features = []

34
gstreamer-player/build.rs Normal file
View file

@ -0,0 +1,34 @@
fn main() {
manage_docs();
}
#[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))]
fn manage_docs() {
extern crate stripper_lib;
use std::io;
let path = "src";
let ignores: &[&str] = &[];
stripper_lib::loop_over_files(
path.as_ref(),
&mut |w, s| stripper_lib::strip_comments(w, s, &mut io::sink(), true),
&ignores,
false,
);
#[cfg(feature = "embed-lgpl-docs")]
{
let docs = include_str!("../docs/gstreamer-player/docs.md");
let mut infos = stripper_lib::parse_cmts(docs.lines(), true);
stripper_lib::loop_over_files(
path.as_ref(),
&mut |w, s| stripper_lib::regenerate_comments(w, s, &mut infos, true, true),
&ignores,
false,
);
}
}
#[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))]
fn manage_docs() {}

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use ffi;

View file

@ -1,9 +1,8 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
mod player;
pub use self::player::Player;
pub use self::player::PlayerExt;
mod player_audio_info;
pub use self::player_audio_info::PlayerAudioInfo;
@ -52,7 +51,6 @@ pub use self::enums::PlayerState;
#[doc(hidden)]
pub mod traits {
pub use super::PlayerExt;
pub use super::PlayerAudioInfoExt;
pub use super::PlayerGMainContextSignalDispatcherExt;
pub use super::PlayerMediaInfoExt;

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use PlayerStreamInfo;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use PlayerSignalDispatcher;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use PlayerAudioInfo;
@ -34,16 +34,12 @@ pub trait PlayerMediaInfoExt {
fn get_image_sample(&self) -> Option<gst::Sample>;
#[cfg(feature = "v1_12")]
fn get_number_of_audio_streams(&self) -> u32;
#[cfg(feature = "v1_12")]
fn get_number_of_streams(&self) -> u32;
#[cfg(feature = "v1_12")]
fn get_number_of_subtitle_streams(&self) -> u32;
#[cfg(feature = "v1_12")]
fn get_number_of_video_streams(&self) -> u32;
fn get_stream_list(&self) -> Vec<PlayerStreamInfo>;
@ -88,28 +84,24 @@ impl<O: IsA<PlayerMediaInfo>> PlayerMediaInfoExt for O {
}
}
#[cfg(feature = "v1_12")]
fn get_number_of_audio_streams(&self) -> u32 {
unsafe {
ffi::gst_player_media_info_get_number_of_audio_streams(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
fn get_number_of_streams(&self) -> u32 {
unsafe {
ffi::gst_player_media_info_get_number_of_streams(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
fn get_number_of_subtitle_streams(&self) -> u32 {
unsafe {
ffi::gst_player_media_info_get_number_of_subtitle_streams(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
fn get_number_of_video_streams(&self) -> u32 {
unsafe {
ffi::gst_player_media_info_get_number_of_video_streams(self.to_glib_none().0)

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use PlayerStreamInfo;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use PlayerStreamInfo;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use PlayerVideoRenderer;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (f00d658) from gir-files (???)
// This file was generated by gir (3294959) from gir-files (???)
// DO NOT EDIT
use ffi;

View file

@ -0,0 +1,46 @@
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate libc;
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern crate gstreamer_sys as gst_ffi;
extern crate gstreamer_player_sys as ffi;
extern crate gstreamer as gst;
#[macro_use]
extern crate glib;
macro_rules! callback_guard {
() => (
let _guard = ::glib::CallbackGuard::new();
)
}
macro_rules! skip_assert_initialized {
() => (
)
}
macro_rules! assert_initialized_main_thread {
() => (
)
}
pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue, Value};
#[cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
mod auto;
pub use auto::*;
pub use auto::traits::*;
mod player;

View file

@ -0,0 +1,46 @@
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use Player;
use PlayerSignalDispatcher;
use PlayerVideoRenderer;
use ffi;
use glib::translate::*;
use gst;
impl Player {
pub fn new(
video_renderer: Option<&PlayerVideoRenderer>,
signal_dispatcher: Option<&PlayerSignalDispatcher>,
) -> Player {
assert_initialized_main_thread!();
let (major, minor, _, _) = gst::version();
if (major, minor) > (1, 12) {
let video_renderer = video_renderer.to_glib_full();
let signal_dispatcher = signal_dispatcher.to_glib_full();
unsafe { from_glib_full(ffi::gst_player_new(video_renderer, signal_dispatcher)) }
} else {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13 in
// https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/gst-libs/gst/player/gstplayer.c?id=634cd87c76f58b5e1383715bafd5614db825c7d1
let video_renderer = video_renderer.to_glib_none();
let signal_dispatcher = signal_dispatcher.to_glib_none();
unsafe { from_glib_none(ffi::gst_player_new(video_renderer.0, signal_dispatcher.0)) }
}
}
#[allow(dead_code)]
fn set_config(&self, config: gst::Structure) -> bool {
unsafe {
from_glib(ffi::gst_player_set_config(
self.to_glib_none().0,
config.into_ptr(),
))
}
}
}