summaryrefslogtreecommitdiff
path: root/gst-sdk
diff options
context:
space:
mode:
authorXavi Artigas <xartigas@fluendo.com>2013-05-21 10:29:18 +0200
committerXavi Artigas <xartigas@fluendo.com>2013-05-21 10:29:18 +0200
commit0df42274ec189c95a7b914cddacaa48aa5a11408 (patch)
treec7dc58792733e6953c3e8c7fbcf0ef36a7e5afc3 /gst-sdk
parent232d63a6b26aeda86957a23af890cafadb53e704 (diff)
Add some code comments.
Diffstat (limited to 'gst-sdk')
-rw-r--r--gst-sdk/tutorials/xcode iOS/Tutorial 4/GStreamerBackend.m71
-rw-r--r--gst-sdk/tutorials/xcode iOS/Tutorial 4/VideoViewController.m17
-rw-r--r--gst-sdk/tutorials/xcode iOS/Tutorial 5/GStreamerBackend.m71
-rw-r--r--gst-sdk/tutorials/xcode iOS/Tutorial 5/VideoViewController.m17
4 files changed, 96 insertions, 80 deletions
diff --git a/gst-sdk/tutorials/xcode iOS/Tutorial 4/GStreamerBackend.m b/gst-sdk/tutorials/xcode iOS/Tutorial 4/GStreamerBackend.m
index fdc0c70..95ac99f 100644
--- a/gst-sdk/tutorials/xcode iOS/Tutorial 4/GStreamerBackend.m
+++ b/gst-sdk/tutorials/xcode iOS/Tutorial 4/GStreamerBackend.m
@@ -184,41 +184,6 @@ static gboolean delayed_seek_cb (GStreamerBackend *self) {
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 */
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 */
static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
{
diff --git a/gst-sdk/tutorials/xcode iOS/Tutorial 4/VideoViewController.m b/gst-sdk/tutorials/xcode iOS/Tutorial 4/VideoViewController.m
index 536082d..2ba6330 100644
--- a/gst-sdk/tutorials/xcode iOS/Tutorial 4/VideoViewController.m
+++ b/gst-sdk/tutorials/xcode iOS/Tutorial 4/VideoViewController.m
@@ -4,11 +4,11 @@
@interface VideoViewController () {
GStreamerBackend *gst_backend;
- int media_width;
- int media_height;
- Boolean dragging_slider;
- Boolean is_local_media;
- Boolean is_playing_desired;
+ int media_width; /* Width of the clip */
+ int media_height; /* height ofthe clip */
+ Boolean dragging_slider; /* Whether the time slider is being dragged or not */
+ Boolean is_local_media; /* Whether this clip is stored locally or is being streamed */
+ Boolean is_playing_desired; /* Whether the user asked to go to PLAYING */
}
@end
@@ -20,6 +20,9 @@
/*
* 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
{
NSInteger position = time_slider.value / 1000;
@@ -94,6 +97,8 @@
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 {
if (!dragging_slider) return;
// 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];
}
+/* Called when the user starts to drag the time slider */
- (IBAction)sliderTouchDown:(id)sender {
[gst_backend pause];
dragging_slider = YES;
}
+/* Called when the user stops dragging the time slider */
- (IBAction)sliderTouchUp:(id)sender {
dragging_slider = NO;
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.
diff --git a/gst-sdk/tutorials/xcode iOS/Tutorial 5/GStreamerBackend.m b/gst-sdk/tutorials/xcode iOS/Tutorial 5/GStreamerBackend.m
index b821f9a..136123a 100644
--- a/gst-sdk/tutorials/xcode iOS/Tutorial 5/GStreamerBackend.m
+++ b/gst-sdk/tutorials/xcode iOS/Tutorial 5/GStreamerBackend.m
@@ -184,41 +184,6 @@ static gboolean delayed_seek_cb (GStreamerBackend *self) {
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 */
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 */
static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self)
{
diff --git a/gst-sdk/tutorials/xcode iOS/Tutorial 5/VideoViewController.m b/gst-sdk/tutorials/xcode iOS/Tutorial 5/VideoViewController.m
index 536082d..54758c9 100644
--- a/gst-sdk/tutorials/xcode iOS/Tutorial 5/VideoViewController.m
+++ b/gst-sdk/tutorials/xcode iOS/Tutorial 5/VideoViewController.m
@@ -4,11 +4,11 @@
@interface VideoViewController () {
GStreamerBackend *gst_backend;
- int media_width;
- int media_height;
- Boolean dragging_slider;
- Boolean is_local_media;
- Boolean is_playing_desired;
+ int media_width; /* Width of the clip */
+ int media_height; /* height ofthe clip */
+ Boolean dragging_slider; /* Whether the time slider is being dragged or not */
+ Boolean is_local_media; /* Whether this clip is stored locally or is being streamed */
+ Boolean is_playing_desired; /* Whether the user asked to go to PLAYING */
}
@end
@@ -20,6 +20,9 @@
/*
* 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
{
NSInteger position = time_slider.value / 1000;
@@ -94,6 +97,8 @@
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 {
if (!dragging_slider) return;
// 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];
}
+/* Called when the user starts to drag the time slider */
- (IBAction)sliderTouchDown:(id)sender {
[gst_backend pause];
dragging_slider = YES;
}
+/* Called when the user stops dragging the time slider */
- (IBAction)sliderTouchUp:(id)sender {
dragging_slider = NO;
// If this is a remote file, scrub seeking is probably not going to work smoothly enough.