Add gst png file save.

This commit is contained in:
Taeho Oh 2016-01-23 18:34:05 +09:00
parent 106a251f17
commit 4ebf609062
3 changed files with 104 additions and 1 deletions

View File

@ -3,7 +3,8 @@ OMVS_VERSION = 0.1
TARGET = omvs TARGET = omvs
OBJS = \ OBJS = \
omvs_main.o omvs_main.o \
omvs_gst.o
CC = gcc CC = gcc
LD = gcc LD = gcc
RM = rm -rf RM = rm -rf

71
omvs_gst.c Normal file
View File

@ -0,0 +1,71 @@
/*
Oh! Multicast Video Scanner
Copyright (C) 2016 Taeho Oh <ohhara@postech.edu>
This file is part of Oh! Multicast Video Scanner.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gst/gst.h>
#include "omvs_gst.h"
typedef struct _OMVSGstImpl {
GstElement *play;
} OMVSGstImpl;
OMVSGst omvs_gst_open(const gchar *uri, const gchar *filename) {
OMVSGstImpl *gst_impl;
GstElement *play;
GstElement *png;
GstElement *file;
GstElement *pngfile;
GstPad *pad;
GstPad *ghostpad;
gst_impl = g_malloc0(sizeof(OMVSGstImpl));
gst_impl->play = play = gst_element_factory_make("playbin", "play");
g_object_set(G_OBJECT(play), "uri", uri, NULL);
png = gst_element_factory_make("pngenc", "png");
g_object_set(G_OBJECT(png), "snapshot", 1, NULL);
file = gst_element_factory_make("multifilesink", "file");
g_object_set(G_OBJECT(file), "max-files", 1, "location", filename, NULL);
pngfile = gst_bin_new("pngfile");
gst_bin_add_many(GST_BIN(pngfile), png, file, NULL);
pad = gst_element_get_static_pad(png, "sink");
ghostpad = gst_ghost_pad_new("sink", pad);
gst_element_add_pad(pngfile, ghostpad);
gst_object_unref(GST_OBJECT(pad));
g_object_set(play, "video-sink", pngfile, NULL);
g_object_set(play, "mute", TRUE, NULL);
gst_element_set_state(play, GST_STATE_PLAYING);
return (OMVSGst)gst_impl;
}
gint omvs_gst_close(OMVSGst gst) {
OMVSGstImpl *gst_impl;
gst_impl = (OMVSGstImpl *)gst;
if (gst_impl) {
gst_element_set_state(gst_impl->play, GST_STATE_NULL);
gst_object_unref(gst_impl->play);
g_free(gst_impl);
}
return 0;
}

31
omvs_gst.h Normal file
View File

@ -0,0 +1,31 @@
/*
Oh! Multicast Video Scanner
Copyright (C) 2016 Taeho Oh <ohhara@postech.edu>
This file is part of Oh! Multicast Video Scanner.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _OMVS_GST_H_
#define _OMVS_GST_H_
#include <glib.h>
typedef void *OMVSGst;
extern OMVSGst omvs_gst_open(const gchar *uri, const gchar *filename);
extern gint omvs_gst_close(OMVSGst gst);
#endif /* _OMVS_GST_H_ */