mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-13 04:41:16 +00:00
Add some code comments.
This commit is contained in:
parent
232d63a6b2
commit
0df42274ec
4 changed files with 96 additions and 80 deletions
|
@ -184,41 +184,6 @@ static gboolean delayed_seek_cb (GStreamerBackend *self) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_media_size (GStreamerBackend *self) {
|
|
||||||
GstElement *video_sink;
|
|
||||||
GstPad *video_sink_pad;
|
|
||||||
GstCaps *caps;
|
|
||||||
GstVideoFormat fmt;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
/* Retrieve the Caps at the entrance of the video sink */
|
|
||||||
g_object_get (self->pipeline, "video-sink", &video_sink, NULL);
|
|
||||||
|
|
||||||
/* Do nothing if there is no video sink (this might be an audio-only clip */
|
|
||||||
if (!video_sink) return;
|
|
||||||
|
|
||||||
video_sink_pad = gst_element_get_static_pad (video_sink, "sink");
|
|
||||||
caps = gst_pad_get_negotiated_caps (video_sink_pad);
|
|
||||||
|
|
||||||
if (gst_video_format_parse_caps(caps, &fmt, &width, &height)) {
|
|
||||||
int par_n, par_d;
|
|
||||||
if (gst_video_parse_caps_pixel_aspect_ratio (caps, &par_n, &par_d)) {
|
|
||||||
width = width * par_n / par_d;
|
|
||||||
}
|
|
||||||
GST_DEBUG ("Media size is %dx%d, notifying application", width, height);
|
|
||||||
|
|
||||||
if (self->ui_delegate && [self->ui_delegate respondsToSelector:@selector(mediaSizeChanged:height:)])
|
|
||||||
{
|
|
||||||
[self->ui_delegate mediaSizeChanged:width height:height];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_caps_unref(caps);
|
|
||||||
gst_object_unref (video_sink_pad);
|
|
||||||
gst_object_unref(video_sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Retrieve errors from the bus and show them on the UI */
|
/* Retrieve errors from the bus and show them on the UI */
|
||||||
static void error_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
static void error_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
||||||
{
|
{
|
||||||
|
@ -276,6 +241,42 @@ static void clock_lost_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieve the video sink's Caps and tell the application about the media size */
|
||||||
|
static void check_media_size (GStreamerBackend *self) {
|
||||||
|
GstElement *video_sink;
|
||||||
|
GstPad *video_sink_pad;
|
||||||
|
GstCaps *caps;
|
||||||
|
GstVideoFormat fmt;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
/* Retrieve the Caps at the entrance of the video sink */
|
||||||
|
g_object_get (self->pipeline, "video-sink", &video_sink, NULL);
|
||||||
|
|
||||||
|
/* Do nothing if there is no video sink (this might be an audio-only clip */
|
||||||
|
if (!video_sink) return;
|
||||||
|
|
||||||
|
video_sink_pad = gst_element_get_static_pad (video_sink, "sink");
|
||||||
|
caps = gst_pad_get_negotiated_caps (video_sink_pad);
|
||||||
|
|
||||||
|
if (gst_video_format_parse_caps(caps, &fmt, &width, &height)) {
|
||||||
|
int par_n, par_d;
|
||||||
|
if (gst_video_parse_caps_pixel_aspect_ratio (caps, &par_n, &par_d)) {
|
||||||
|
width = width * par_n / par_d;
|
||||||
|
}
|
||||||
|
GST_DEBUG ("Media size is %dx%d, notifying application", width, height);
|
||||||
|
|
||||||
|
if (self->ui_delegate && [self->ui_delegate respondsToSelector:@selector(mediaSizeChanged:height:)])
|
||||||
|
{
|
||||||
|
[self->ui_delegate mediaSizeChanged:width height:height];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_caps_unref(caps);
|
||||||
|
gst_object_unref (video_sink_pad);
|
||||||
|
gst_object_unref(video_sink);
|
||||||
|
}
|
||||||
|
|
||||||
/* Notify UI about pipeline state changes */
|
/* Notify UI about pipeline state changes */
|
||||||
static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
@interface VideoViewController () {
|
@interface VideoViewController () {
|
||||||
GStreamerBackend *gst_backend;
|
GStreamerBackend *gst_backend;
|
||||||
int media_width;
|
int media_width; /* Width of the clip */
|
||||||
int media_height;
|
int media_height; /* height ofthe clip */
|
||||||
Boolean dragging_slider;
|
Boolean dragging_slider; /* Whether the time slider is being dragged or not */
|
||||||
Boolean is_local_media;
|
Boolean is_local_media; /* Whether this clip is stored locally or is being streamed */
|
||||||
Boolean is_playing_desired;
|
Boolean is_playing_desired; /* Whether the user asked to go to PLAYING */
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -20,6 +20,9 @@
|
||||||
/*
|
/*
|
||||||
* Private methods
|
* Private methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The text widget acts as an slave for the seek bar, so it reflects what the seek bar shows, whether
|
||||||
|
* it is an actual pipeline position or the position the user is currently dragging to. */
|
||||||
- (void) updateTimeWidget
|
- (void) updateTimeWidget
|
||||||
{
|
{
|
||||||
NSInteger position = time_slider.value / 1000;
|
NSInteger position = time_slider.value / 1000;
|
||||||
|
@ -94,6 +97,8 @@
|
||||||
is_playing_desired = NO;
|
is_playing_desired = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when the time slider position has changed, either because the user dragged it or
|
||||||
|
* we programmatically changed its position. dragging_slider tells us which one happened */
|
||||||
- (IBAction)sliderValueChanged:(id)sender {
|
- (IBAction)sliderValueChanged:(id)sender {
|
||||||
if (!dragging_slider) return;
|
if (!dragging_slider) return;
|
||||||
// If this is a local file, allow scrub seeking, this is, seek as soon as the slider is moved.
|
// If this is a local file, allow scrub seeking, this is, seek as soon as the slider is moved.
|
||||||
|
@ -102,11 +107,13 @@
|
||||||
[self updateTimeWidget];
|
[self updateTimeWidget];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when the user starts to drag the time slider */
|
||||||
- (IBAction)sliderTouchDown:(id)sender {
|
- (IBAction)sliderTouchDown:(id)sender {
|
||||||
[gst_backend pause];
|
[gst_backend pause];
|
||||||
dragging_slider = YES;
|
dragging_slider = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when the user stops dragging the time slider */
|
||||||
- (IBAction)sliderTouchUp:(id)sender {
|
- (IBAction)sliderTouchUp:(id)sender {
|
||||||
dragging_slider = NO;
|
dragging_slider = NO;
|
||||||
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
|
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
|
||||||
|
|
|
@ -184,41 +184,6 @@ static gboolean delayed_seek_cb (GStreamerBackend *self) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_media_size (GStreamerBackend *self) {
|
|
||||||
GstElement *video_sink;
|
|
||||||
GstPad *video_sink_pad;
|
|
||||||
GstCaps *caps;
|
|
||||||
GstVideoFormat fmt;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
/* Retrieve the Caps at the entrance of the video sink */
|
|
||||||
g_object_get (self->pipeline, "video-sink", &video_sink, NULL);
|
|
||||||
|
|
||||||
/* Do nothing if there is no video sink (this might be an audio-only clip */
|
|
||||||
if (!video_sink) return;
|
|
||||||
|
|
||||||
video_sink_pad = gst_element_get_static_pad (video_sink, "sink");
|
|
||||||
caps = gst_pad_get_negotiated_caps (video_sink_pad);
|
|
||||||
|
|
||||||
if (gst_video_format_parse_caps(caps, &fmt, &width, &height)) {
|
|
||||||
int par_n, par_d;
|
|
||||||
if (gst_video_parse_caps_pixel_aspect_ratio (caps, &par_n, &par_d)) {
|
|
||||||
width = width * par_n / par_d;
|
|
||||||
}
|
|
||||||
GST_DEBUG ("Media size is %dx%d, notifying application", width, height);
|
|
||||||
|
|
||||||
if (self->ui_delegate && [self->ui_delegate respondsToSelector:@selector(mediaSizeChanged:height:)])
|
|
||||||
{
|
|
||||||
[self->ui_delegate mediaSizeChanged:width height:height];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_caps_unref(caps);
|
|
||||||
gst_object_unref (video_sink_pad);
|
|
||||||
gst_object_unref(video_sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Retrieve errors from the bus and show them on the UI */
|
/* Retrieve errors from the bus and show them on the UI */
|
||||||
static void error_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
static void error_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
||||||
{
|
{
|
||||||
|
@ -276,6 +241,42 @@ static void clock_lost_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieve the video sink's Caps and tell the application about the media size */
|
||||||
|
static void check_media_size (GStreamerBackend *self) {
|
||||||
|
GstElement *video_sink;
|
||||||
|
GstPad *video_sink_pad;
|
||||||
|
GstCaps *caps;
|
||||||
|
GstVideoFormat fmt;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
/* Retrieve the Caps at the entrance of the video sink */
|
||||||
|
g_object_get (self->pipeline, "video-sink", &video_sink, NULL);
|
||||||
|
|
||||||
|
/* Do nothing if there is no video sink (this might be an audio-only clip */
|
||||||
|
if (!video_sink) return;
|
||||||
|
|
||||||
|
video_sink_pad = gst_element_get_static_pad (video_sink, "sink");
|
||||||
|
caps = gst_pad_get_negotiated_caps (video_sink_pad);
|
||||||
|
|
||||||
|
if (gst_video_format_parse_caps(caps, &fmt, &width, &height)) {
|
||||||
|
int par_n, par_d;
|
||||||
|
if (gst_video_parse_caps_pixel_aspect_ratio (caps, &par_n, &par_d)) {
|
||||||
|
width = width * par_n / par_d;
|
||||||
|
}
|
||||||
|
GST_DEBUG ("Media size is %dx%d, notifying application", width, height);
|
||||||
|
|
||||||
|
if (self->ui_delegate && [self->ui_delegate respondsToSelector:@selector(mediaSizeChanged:height:)])
|
||||||
|
{
|
||||||
|
[self->ui_delegate mediaSizeChanged:width height:height];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_caps_unref(caps);
|
||||||
|
gst_object_unref (video_sink_pad);
|
||||||
|
gst_object_unref(video_sink);
|
||||||
|
}
|
||||||
|
|
||||||
/* Notify UI about pipeline state changes */
|
/* Notify UI about pipeline state changes */
|
||||||
static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
@interface VideoViewController () {
|
@interface VideoViewController () {
|
||||||
GStreamerBackend *gst_backend;
|
GStreamerBackend *gst_backend;
|
||||||
int media_width;
|
int media_width; /* Width of the clip */
|
||||||
int media_height;
|
int media_height; /* height ofthe clip */
|
||||||
Boolean dragging_slider;
|
Boolean dragging_slider; /* Whether the time slider is being dragged or not */
|
||||||
Boolean is_local_media;
|
Boolean is_local_media; /* Whether this clip is stored locally or is being streamed */
|
||||||
Boolean is_playing_desired;
|
Boolean is_playing_desired; /* Whether the user asked to go to PLAYING */
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -20,6 +20,9 @@
|
||||||
/*
|
/*
|
||||||
* Private methods
|
* Private methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* The text widget acts as an slave for the seek bar, so it reflects what the seek bar shows, whether
|
||||||
|
* it is an actual pipeline position or the position the user is currently dragging to. */
|
||||||
- (void) updateTimeWidget
|
- (void) updateTimeWidget
|
||||||
{
|
{
|
||||||
NSInteger position = time_slider.value / 1000;
|
NSInteger position = time_slider.value / 1000;
|
||||||
|
@ -94,6 +97,8 @@
|
||||||
is_playing_desired = NO;
|
is_playing_desired = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when the time slider position has changed, either because the user dragged it or
|
||||||
|
* we programmatically changed its position. dragging_slider tells us which one happened */
|
||||||
- (IBAction)sliderValueChanged:(id)sender {
|
- (IBAction)sliderValueChanged:(id)sender {
|
||||||
if (!dragging_slider) return;
|
if (!dragging_slider) return;
|
||||||
// If this is a local file, allow scrub seeking, this is, seek as soon as the slider is moved.
|
// If this is a local file, allow scrub seeking, this is, seek as soon as the slider is moved.
|
||||||
|
@ -102,11 +107,13 @@
|
||||||
[self updateTimeWidget];
|
[self updateTimeWidget];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when the user starts to drag the time slider */
|
||||||
- (IBAction)sliderTouchDown:(id)sender {
|
- (IBAction)sliderTouchDown:(id)sender {
|
||||||
[gst_backend pause];
|
[gst_backend pause];
|
||||||
dragging_slider = YES;
|
dragging_slider = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when the user stops dragging the time slider */
|
||||||
- (IBAction)sliderTouchUp:(id)sender {
|
- (IBAction)sliderTouchUp:(id)sender {
|
||||||
dragging_slider = NO;
|
dragging_slider = NO;
|
||||||
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
|
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
|
||||||
|
|
Loading…
Reference in a new issue