~oah-dev/oah/gst-plugins-bad

« back to all changes in this revision

Viewing changes to tests/icles/dccp/file/DCCPServerSendFile.c

  • Committer: Haakon Sporsheim
  • Date: 2009-03-12 13:52:03 UTC
  • Revision ID: haakon.sporsheim@tandberg.com-20090312135203-i5k294hgkushb0mt
Initial import of git repository: git://anongit.freedesktop.org/gstreamer/gst-plugins-bad (tag: RELEASE-0_10_10)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GStreamer
 
2
 * Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Library General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Library General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#include <stdio.h>
 
21
#include <stdlib.h>
 
22
#include <gst/gst.h>
 
23
 
 
24
static gboolean
 
25
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
 
26
{
 
27
 
 
28
  GMainLoop *loop = (GMainLoop *) data;
 
29
 
 
30
  switch (GST_MESSAGE_TYPE (msg)) {
 
31
    case GST_MESSAGE_EOS:
 
32
      g_print ("End-of-stream\n");
 
33
      g_main_loop_quit (loop);
 
34
      break;
 
35
    case GST_MESSAGE_ERROR:{
 
36
      gchar *debug;
 
37
      GError *err;
 
38
 
 
39
      gst_message_parse_error (msg, &err, &debug);
 
40
      g_free (debug);
 
41
 
 
42
      g_print ("Error: %s\n", err->message);
 
43
      g_error_free (err);
 
44
 
 
45
      g_main_loop_quit (loop);
 
46
      break;
 
47
    }
 
48
    default:
 
49
      break;
 
50
  }
 
51
 
 
52
  return TRUE;
 
53
}
 
54
 
 
55
 
 
56
int
 
57
main (int argc, char *argv[])
 
58
{
 
59
 
 
60
  GMainLoop *loop;
 
61
  GstBus *bus;
 
62
  GstElement *pipeline, *filesrc, *dccpserversink;
 
63
 
 
64
  /* initialize GStreamer */
 
65
  gst_init (&argc, &argv);
 
66
  loop = g_main_loop_new (NULL, FALSE);
 
67
 
 
68
  /* check input arguments */
 
69
  if (argc != 3) {
 
70
    g_print ("%s\n", "see usage: port mp3Location");
 
71
    return -1;
 
72
  }
 
73
 
 
74
  /* create elements */
 
75
  pipeline = gst_pipeline_new ("audio-sender");
 
76
  filesrc = gst_element_factory_make ("filesrc", "file-source");
 
77
  dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
 
78
 
 
79
 
 
80
  if (!pipeline || !filesrc || !dccpserversink) {
 
81
    g_print ("One element could not be created\n");
 
82
    return -1;
 
83
  }
 
84
 
 
85
  g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
 
86
  /*g_object_set (G_OBJECT (dccpserversink), "ccid", 3, NULL); */
 
87
  g_object_set (G_OBJECT (filesrc), "location", argv[2], NULL);
 
88
 
 
89
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
 
90
  gst_bus_add_watch (bus, bus_call, loop);
 
91
  gst_object_unref (bus);
 
92
 
 
93
  /* put all elements in a bin */
 
94
  gst_bin_add_many (GST_BIN (pipeline), filesrc, dccpserversink, NULL);
 
95
 
 
96
  gst_element_link_many (filesrc, dccpserversink, NULL);
 
97
 
 
98
 
 
99
  /* Now set to playing and iterate. */
 
100
  g_print ("Setting to PLAYING\n");
 
101
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
 
102
  g_print ("Running\n");
 
103
  g_main_loop_run (loop);
 
104
 
 
105
  /* clean up nicely */
 
106
  g_print ("Returned, stopping playback\n");
 
107
  gst_element_set_state (pipeline, GST_STATE_NULL);
 
108
  g_print ("Deleting pipeline\n");
 
109
  gst_object_unref (GST_OBJECT (pipeline));
 
110
 
 
111
  return 0;
 
112
}