mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
Merge remote-tracking branch 'origin/master' into 0.11
Conflicts: tests/examples/camerabin2/Makefile.am
This commit is contained in:
commit
4917e16458
6 changed files with 205 additions and 18 deletions
|
@ -152,6 +152,8 @@ gst_base_video_codec_reset (GstBaseVideoCodec * base_video_codec)
|
|||
|
||||
gst_buffer_replace (&base_video_codec->state.codec_data, NULL);
|
||||
gst_caps_replace (&base_video_codec->state.caps, NULL);
|
||||
memset (&base_video_codec->state, 0, sizeof (GstVideoState));
|
||||
base_video_codec->state.format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||
GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_codec);
|
||||
}
|
||||
|
||||
|
|
|
@ -1688,7 +1688,7 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
|
|||
NULL);
|
||||
|
||||
if (camera->video_profile_switch) {
|
||||
GST_DEBUG_OBJECT (camera, "Switching encodebin's profile");
|
||||
GST_DEBUG_OBJECT (camera, "Switching video-encodebin's profile");
|
||||
g_object_set (camera->video_encodebin, "profile", camera->video_profile,
|
||||
NULL);
|
||||
if (GST_PAD_LINK_FAILED (gst_camera_bin_link_encodebin (camera,
|
||||
|
@ -1703,7 +1703,7 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
|
|||
}
|
||||
|
||||
if (camera->image_profile_switch) {
|
||||
GST_DEBUG_OBJECT (camera, "Switching encodebin's profile");
|
||||
GST_DEBUG_OBJECT (camera, "Switching image-encodebin's profile");
|
||||
g_object_set (camera->image_encodebin, "profile", camera->image_profile,
|
||||
NULL);
|
||||
if (GST_PAD_LINK_FAILED (gst_camera_bin_link_encodebin (camera,
|
||||
|
|
|
@ -15,7 +15,7 @@ gst_camera2_LDADD = \
|
|||
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la \
|
||||
$(GST_PLUGINS_BASE_LIBS) \
|
||||
-lgstinterfaces-@GST_MAJORMINOR@ \
|
||||
-lgstvideo-@GST_MAJORMINOR@ \
|
||||
-lgstpbutils-@GST_MAJORMINOR@ \
|
||||
$(GST_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(GMODULE_EXPORT_LIBS)
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
#include "gst-camera2.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gst/pbutils/encoding-profile.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/videooverlay.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -41,6 +44,78 @@
|
|||
|
||||
static GstElement *camera;
|
||||
static GtkBuilder *builder;
|
||||
static GtkWidget *ui_main_window;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const gchar *name;
|
||||
GstEncodingProfile *(*create_profile) ();
|
||||
} GstCameraVideoFormat;
|
||||
|
||||
static GstEncodingProfile *
|
||||
create_ogg_profile (void)
|
||||
{
|
||||
GstEncodingContainerProfile *container;
|
||||
|
||||
container = gst_encoding_container_profile_new ("ogg", NULL,
|
||||
gst_caps_new_empty_simple ("application/ogg"), NULL);
|
||||
|
||||
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
|
||||
gst_encoding_video_profile_new (gst_caps_new_empty_simple
|
||||
("video/x-theora"), NULL, NULL, 1));
|
||||
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
|
||||
gst_encoding_audio_profile_new (gst_caps_new_empty_simple
|
||||
("audio/x-vorbis"), NULL, NULL, 1));
|
||||
|
||||
return (GstEncodingProfile *) container;
|
||||
}
|
||||
|
||||
static GstEncodingProfile *
|
||||
create_webm_profile (void)
|
||||
{
|
||||
GstEncodingContainerProfile *container;
|
||||
|
||||
container = gst_encoding_container_profile_new ("webm", NULL,
|
||||
gst_caps_new_empty_simple ("video/webm"), NULL);
|
||||
|
||||
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
|
||||
gst_encoding_video_profile_new (gst_caps_new_empty_simple ("video/x-vp8"),
|
||||
NULL, NULL, 1));
|
||||
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
|
||||
gst_encoding_audio_profile_new (gst_caps_new_empty_simple
|
||||
("audio/x-vorbis"), NULL, NULL, 1));
|
||||
|
||||
return (GstEncodingProfile *) container;
|
||||
}
|
||||
|
||||
static GstEncodingProfile *
|
||||
create_mp4_profile (void)
|
||||
{
|
||||
GstEncodingContainerProfile *container;
|
||||
|
||||
container = gst_encoding_container_profile_new ("mp4", NULL,
|
||||
gst_caps_new_simple ("video/quicktime", "variant", G_TYPE_STRING, "iso",
|
||||
NULL), NULL);
|
||||
|
||||
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
|
||||
gst_encoding_video_profile_new (gst_caps_new_empty_simple
|
||||
("video/x-h264"), NULL, NULL, 1));
|
||||
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
|
||||
gst_encoding_audio_profile_new (gst_caps_new_simple ("audio/mpeg",
|
||||
"version", G_TYPE_INT, 4, NULL), NULL, NULL, 1));
|
||||
|
||||
return (GstEncodingProfile *) container;
|
||||
}
|
||||
|
||||
GstCameraVideoFormat formats[] = {
|
||||
{"ogg (theora/vorbis)", create_ogg_profile}
|
||||
,
|
||||
{"webm (vp8/vorbis)", create_webm_profile}
|
||||
,
|
||||
{"mp4 (h264+aac)", create_mp4_profile}
|
||||
,
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
void
|
||||
on_mainWindow_delete_event (GtkWidget * widget, GdkEvent * event, gpointer data)
|
||||
|
@ -84,6 +159,36 @@ on_viewfinderArea_realize (GtkWidget * widget, gpointer data)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
on_formatComboBox_changed (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
GstEncodingProfile *profile = NULL;
|
||||
gint index = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
|
||||
|
||||
if (formats[index].create_profile) {
|
||||
profile = formats[index].create_profile ();
|
||||
}
|
||||
|
||||
g_return_if_fail (profile != NULL);
|
||||
gst_element_set_state (camera, GST_STATE_NULL);
|
||||
g_object_set (camera, "video-profile", profile, NULL);
|
||||
gst_encoding_profile_unref (profile);
|
||||
|
||||
if (GST_STATE_CHANGE_FAILURE == gst_element_set_state (camera,
|
||||
GST_STATE_PLAYING)) {
|
||||
GtkWidget *dialog =
|
||||
gtk_message_dialog_new (GTK_WINDOW (ui_main_window), GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
|
||||
"Could not initialize camerabin2 with the "
|
||||
"selected format. Your system might not have the required plugins installed.\n"
|
||||
"Please select another format.");
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static GstBusSyncReply
|
||||
bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||
{
|
||||
|
@ -152,11 +257,28 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
init_gtkwidgets_data (void)
|
||||
{
|
||||
gint i;
|
||||
GtkComboBoxText *combobox =
|
||||
GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder, "formatComboBox"));
|
||||
|
||||
/* init formats combobox */
|
||||
i = 0;
|
||||
while (formats[i].name) {
|
||||
gtk_combo_box_text_append_text (combobox, formats[i].name);
|
||||
i++;
|
||||
}
|
||||
|
||||
/* default to the first one -> ogg */
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
GtkWidget *ui_main_window;
|
||||
GError *error = NULL;
|
||||
GstBus *bus;
|
||||
|
||||
|
@ -176,6 +298,8 @@ main (int argc, char *argv[])
|
|||
gst_bus_set_sync_handler (bus, bus_sync_callback, NULL);
|
||||
gst_object_unref (bus);
|
||||
|
||||
init_gtkwidgets_data ();
|
||||
|
||||
ui_main_window = GTK_WIDGET (gtk_builder_get_object (builder, "mainWindow"));
|
||||
gtk_builder_connect_signals (builder, NULL);
|
||||
gtk_widget_show_all (ui_main_window);
|
||||
|
|
|
@ -45,4 +45,7 @@ on_videoRButton_toggled (GtkToggleButton * button, gpointer user_data);
|
|||
void
|
||||
on_viewfinderArea_realize (GtkWidget * widget, gpointer data);
|
||||
|
||||
void
|
||||
on_formatComboBox_changed (GtkWidget * widget, gpointer data);
|
||||
|
||||
#endif /* __GST_CAMERA_BIN_H__ */
|
||||
|
|
|
@ -1,43 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkWindow" id="mainWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="default_width">800</property>
|
||||
<property name="default_height">600</property>
|
||||
<signal name="delete_event" handler="on_mainWindow_delete_event"/>
|
||||
<signal name="delete-event" handler="on_mainWindow_delete_event" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="imageRButton">
|
||||
<property name="label" translatable="yes">Image</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_imageRButton_toggled"/>
|
||||
<signal name="toggled" handler="on_imageRButton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="videoRButton">
|
||||
<property name="label" translatable="yes">Video</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">imageRButton</property>
|
||||
<signal name="toggled" handler="on_videoRButton_toggled"/>
|
||||
<signal name="toggled" handler="on_videoRButton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -51,39 +61,44 @@
|
|||
<child>
|
||||
<object class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="viewfinderArea">
|
||||
<property name="visible">True</property>
|
||||
<signal name="realize" handler="on_viewfinderArea_realize"/>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="realize" handler="on_viewfinderArea_realize" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="captureButton">
|
||||
<property name="label" translatable="yes">Capture</property>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_captureButton_clicked"/>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Actions</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="stopCaptureButton">
|
||||
<property name="label" translatable="yes">Stop Capture</property>
|
||||
<object class="GtkButton" id="captureButton">
|
||||
<property name="label" translatable="yes">Capture</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_stopCaptureButton_clicked"/>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<signal name="clicked" handler="on_captureButton_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -91,6 +106,47 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="stopCaptureButton">
|
||||
<property name="label" translatable="yes">Stop Capture</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<signal name="clicked" handler="on_stopCaptureButton_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Video format</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="padding">5</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="formatComboBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="changed" handler="on_formatComboBox_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -100,6 +156,8 @@
|
|||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
|
Loading…
Reference in a new issue