First pass at cleaning up tests/ dir before moving the rest

Original commit message from CVS:
* configure.ac:
* tests/bench-complexity.scm:
* tests/bench-mass_elements.scm:
* tests/complexity.c:
* tests/complexity.gnuplot:
* tests/instantiate/.cvsignore:
* tests/instantiate/Makefile.am:
* tests/instantiate/caps.c:
* tests/mass_elements.c:
* tests/network-clock-utils.scm:
* tests/network-clock.scm:
* tests/plot-data:
First pass at cleaning up tests/ dir before moving the rest
Combined with CVS surgery
This commit is contained in:
Thomas Vander Stichele 2005-11-30 13:08:08 +00:00
parent f3c23f96fa
commit 78adfea0f0
41 changed files with 47 additions and 4269 deletions

View file

@ -1,3 +1,50 @@
2005-11-30 Thomas Vander Stichele <thomas at apestaart dot org>
* docs/gst/gstreamer-sections.txt:
* tests/sched/.cvsignore:
* tests/sched/Makefile.am:
* tests/sched/cases/(fs-fs).xml:
* tests/sched/cases/(fs-i-fs).xml:
* tests/sched/cases/(fs-i-i-fs).xml:
* tests/sched/cases/(fs-i-q[i-fs]).xml:
* tests/sched/dynamic-pipeline.c:
* tests/sched/interrupt1.c:
* tests/sched/interrupt2.c:
* tests/sched/interrupt3.c:
* tests/sched/runtestcases:
* tests/sched/runxml.c:
* tests/sched/sched-stress.c:
* tests/sched/sort.c:
* tests/sched/testcases:
* tests/sched/testcases1.tc:
* tests/seeking/.cvsignore:
* tests/seeking/Makefile.am:
* tests/seeking/seeking1.c:
* tests/threadstate/.cvsignore:
* tests/threadstate/Makefile.am:
* tests/threadstate/test1.c:
* tests/threadstate/test2.c:
* tests/threadstate/threadstate1.c:
* tests/threadstate/threadstate2.c:
* tests/threadstate/threadstate3.c:
* tests/threadstate/threadstate4.c:
* tests/threadstate/threadstate5.c:
remove obsolete tests
* configure.ac:
* tests/bench-complexity.scm:
* tests/bench-mass_elements.scm:
* tests/complexity.c:
* tests/complexity.gnuplot:
* tests/instantiate/.cvsignore:
* tests/instantiate/Makefile.am:
* tests/instantiate/caps.c:
* tests/mass_elements.c:
* tests/network-clock-utils.scm:
* tests/network-clock.scm:
* tests/plot-data:
First pass at cleaning up tests/ dir before moving the rest
Combined with CVS surgery
2005-11-30 Thomas Vander Stichele <thomas at apestaart dot org>
* po/POTFILES.in:

View file

@ -487,10 +487,6 @@ plugins/elements/Makefile
po/Makefile.in
check/Makefile
tests/Makefile
tests/instantiate/Makefile
tests/seeking/Makefile
tests/sched/Makefile
tests/threadstate/Makefile
testsuite/Makefile
testsuite/caps/Makefile
testsuite/debug/Makefile

View file

@ -1,69 +0,0 @@
#!/bin/bash
# -*- scheme -*-
exec guile -s $0 "$@"
!#
;; Quick hack to make some data files that gnuplot can read from
;; complexity. Guile 1.6.
(use-modules (srfi srfi-13)
(srfi srfi-1)
(ice-9 optargs)
(ice-9 popen))
(define *phases* '(create set run destroy))
(define (read-lines port)
(let lp ((lines '()))
(let ((x (read-line port)))
(if (eof-object? x)
(begin
(close-port port)
(reverse! lines))
(lp (cons x lines))))))
(define (parse-time str)
(and (char-numeric? (string-ref str 0))
(fold (lambda (x ret) (+ (* ret 60) x)) 0
(map (lambda (x) (with-input-from-string x read))
(string-split str #\:)))))
(define (run-test program . args)
(format #t "; running test: ~a\n" (cons program args))
(map
cons
*phases*
(filter-map
parse-time
(read-lines
(open-input-pipe
(string-join (map object->string (cons program args)) " "))))))
(define (seq start stop step)
(let lp ((n start) (out '()))
(if (> n stop)
(reverse! out)
(lp (+ n step) (cons n out)))))
(define (run-tests n-elements)
(let lp ((x 1) (out '()))
(if (> x n-elements)
(reverse! out)
(lp (* x 2)
(acons x (run-test "./complexity" x n-elements) out)))))
(define (output-results results)
(let ((p (open-output-file "complexity.data")))
(display "#complexity creation state-change run destroy\n" p)
(for-each
(lambda (line)
(display (car line) p)
(for-each
(lambda (t) (format p " ~a" t))
(map cdr (cdr line)))
(newline p))
results)
(close-port p)))
(output-results
(apply run-tests (map string->number (cdr (program-arguments)))))

View file

@ -1,68 +0,0 @@
#!/bin/bash
# -*- scheme -*-
exec guile -s $0 "$@"
!#
;; Quick hack to make some data files that gnuplot can read from
;; mass-elements. Guile 1.6.
(use-modules (srfi srfi-13)
(srfi srfi-1)
(ice-9 optargs)
(ice-9 popen))
(define *phases* '(create set run destroy))
(define (read-lines port)
(let lp ((lines '()))
(let ((x (read-line port)))
(if (eof-object? x)
(begin
(close-port port)
(reverse! lines))
(lp (cons x lines))))))
(define (run-test n-identities)
(format #t "; running test: ~a\n" n-identities)
(let lp ((in (read-lines
(open-input-pipe
(format #f "./mass_elements ~A"
(number->string n-identities)))))
(out '()))
(if (null? in)
(begin
(or (eq? (length out) 4) (error "Invalid mass_elements output"))
(map cons *phases* (reverse! out)))
(let ((line (car in)))
(if (eqv? (string-ref line 0) #\*)
(lp (cdr in) out)
(lp (cdr in)
(cons (fold (lambda (x ret) (+ (* ret 60) x)) 0
(map (lambda (x) (with-input-from-string x read))
(string-split line #\:)))
out)))))))
(define (run-tests start stop step)
(let lp ((n start) (out '()))
(if (> n stop)
(reverse! out)
(lp (+ n step)
(acons n (run-test n) out)))))
(define (output-results results)
(let ((p (open-output-file "mass_elements.data")))
(display "#num_identities creation state-change run destroy\n" p)
(let lp ((in results))
(if (not (null? in))
(let* ((line (car in))
(n (car line)))
(display n p)
(for-each
(lambda (t) (format p " ~a" t))
(map cdr (cdr line)))
(newline p)
(lp (cdr in)))))
(close-port p)))
(output-results
(apply run-tests (map string->number (cdr (program-arguments)))))

View file

@ -1,134 +0,0 @@
/*
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
*
* This library 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 2 of the License, or (at your option) any later version.
*
* This library 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 library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gst/gst.h>
#define BUFFER_COUNT (1000)
#define SRC_ELEMENT "fakesrc"
#define SINK_ELEMENT "fakesink"
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline, *src, *e;
GSList *saved_src_list, *src_list, *new_src_list;
guint complexity_order, n_elements, i, j, max_this_level;
GstClockTime start, end;
gboolean all_srcs_linked;
gst_init (&argc, &argv);
if (argc != 3) {
g_print ("usage: %s COMPLEXITY_ORDER N_ELEMENTS\n", argv[0]);
return 1;
}
complexity_order = atoi (argv[1]);
n_elements = atoi (argv[2]);
start = gst_get_current_time ();
pipeline = gst_element_factory_make ("pipeline", NULL);
g_assert (pipeline);
e = gst_element_factory_make ("fakesrc", NULL);
g_object_set (e, "num-buffers", BUFFER_COUNT, NULL);
g_object_set (e, "silent", TRUE, NULL);
gst_bin_add (GST_BIN (pipeline), e);
src_list = saved_src_list = g_slist_append (NULL, e);
new_src_list = NULL;
max_this_level = 1;
j = 0;
i = 0;
all_srcs_linked = FALSE;
for (i = 0, j = 0; i < n_elements; i++, j++) {
if (j >= max_this_level) {
g_slist_free (saved_src_list);
saved_src_list = g_slist_reverse (new_src_list);
new_src_list = NULL;
j = 0;
all_srcs_linked = FALSE;
max_this_level *= complexity_order;
}
if (!src_list) {
if (j)
all_srcs_linked = TRUE;
src_list = saved_src_list;
}
src = (GstElement *) src_list->data;
src_list = src_list->next;
if (i + max_this_level < n_elements) {
e = gst_element_factory_make ("tee", NULL);
} else {
e = gst_element_factory_make ("fakesink", NULL);
g_object_set (e, "preroll-queue-len", 1, NULL);
}
g_object_set (e, "silent", TRUE, NULL);
new_src_list = g_slist_prepend (new_src_list, e);
gst_bin_add (GST_BIN (pipeline), e);
if (!gst_element_link (src, e))
g_assert_not_reached ();
}
g_slist_free (saved_src_list);
g_slist_free (new_src_list);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - creating and linking %d elements\n",
GST_TIME_ARGS (end - start), i);
start = gst_get_current_time ();
if (gst_element_set_state (pipeline,
GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
GST_TIME_ARGS (end - start));
start = gst_get_current_time ();
gst_bus_poll (gst_element_get_bus (pipeline),
GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
GST_TIME_ARGS (end - start), BUFFER_COUNT);
start = gst_get_current_time ();
g_object_unref (pipeline);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
GST_TIME_ARGS (end - start));
return 0;
}

View file

@ -1,9 +0,0 @@
set terminal postscript landscape monochrome dashed "Helvetica" 14
set xlabel "Number of Forks Per Tee"
set ylabel "Seconds"
set logscale x
set title "Complex Pipeline Performance: N Forks per Tee, 1024 Elements"
plot "complexity.data" using 1:2 title "Element creation", \
"complexity.data" using 1:3 title "State change", \
"complexity.data" using 1:4 title "Processing 1000 buffers", \
"complexity.data" using 1:5 title "Element destruction"

View file

@ -1,14 +0,0 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
*.bb
*.bbg
*.da
caps
create

View file

@ -1,4 +0,0 @@
noinst_PROGRAMS = caps
LDADD = $(GST_OBJ_LIBS)
AM_CFLAGS = $(GST_OBJ_CFLAGS)

View file

@ -1,80 +0,0 @@
/* GStreamer
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
*
* caps.c: benchmark for caps creation and destruction
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
#define NUM_CAPS 10000
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, MAX ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) { 8, 16, 24, 32 }, " \
"depth = (int) [ 1, 32 ], " \
"signed = (boolean) { true, false }"
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
gint
main (gint argc, gchar * argv[])
{
GstCaps **capses;
GstCaps *protocaps;
GstClockTime start, end;
gint i;
gst_init (&argc, &argv);
protocaps = gst_caps_from_string (GST_AUDIO_INT_PAD_TEMPLATE_CAPS);
start = gst_get_current_time ();
capses = g_new (GstCaps *, NUM_CAPS);
for (i = 0; i < NUM_CAPS; i++)
capses[i] = gst_caps_copy (protocaps);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - creating %d caps\n",
GST_TIME_ARGS (end - start), i);
start = gst_get_current_time ();
for (i = 0; i < NUM_CAPS; i++)
gst_caps_unref (capses[i]);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - destroying %d caps\n",
GST_TIME_ARGS (end - start), i);
g_free (capses);
gst_caps_unref (protocaps);
return 0;
}

View file

@ -1,112 +0,0 @@
/*
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
*
* This library 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 2 of the License, or (at your option) any later version.
*
* This library 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 library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gst/gst.h>
#define IDENTITY_COUNT (1000)
#define BUFFER_COUNT (1000)
#define SRC_ELEMENT "fakesrc"
#define SINK_ELEMENT "fakesink"
static GstClockTime
gst_get_current_time (void)
{
GTimeVal tv;
g_get_current_time (&tv);
return GST_TIMEVAL_TO_TIME (tv);
}
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline, *src, *sink, *current, *last;
guint i, buffers = BUFFER_COUNT, identities = IDENTITY_COUNT;
GstClockTime start, end;
gchar *src_name = SRC_ELEMENT, *sink_name = SINK_ELEMENT;
gst_init (&argc, &argv);
if (argc > 1)
identities = atoi (argv[1]);
if (argc > 2)
buffers = atoi (argv[2]);
if (argc > 3)
src_name = argv[3];
if (argc > 4)
sink_name = argv[4];
g_print
("*** benchmarking this pipeline: %s num-buffers=%u ! %u * identity ! %s\n",
src_name, buffers, identities, sink_name);
start = gst_get_current_time ();
pipeline = gst_element_factory_make ("pipeline", NULL);
g_assert (pipeline);
src = gst_element_factory_make (src_name, NULL);
if (!src) {
g_print ("no element named \"%s\" found, aborting...\n", src_name);
return 1;
}
g_object_set (src, "num-buffers", buffers, NULL);
sink = gst_element_factory_make (sink_name, NULL);
if (!sink) {
g_print ("no element named \"%s\" found, aborting...\n", sink_name);
return 1;
}
last = src;
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
for (i = 0; i < identities; i++) {
current = gst_element_factory_make ("identity", NULL);
g_assert (current);
/* shut this element up (no g_strdup_printf please) */
g_object_set (current, "silent", TRUE, NULL);
gst_bin_add (GST_BIN (pipeline), current);
if (!gst_element_link (last, current))
g_assert_not_reached ();
last = current;
}
if (!gst_element_link (last, sink))
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n",
GST_TIME_ARGS (end - start), identities);
start = gst_get_current_time ();
if (gst_element_set_state (pipeline,
GST_STATE_PLAYING) != GST_STATE_CHANGE_SUCCESS)
g_assert_not_reached ();
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
GST_TIME_ARGS (end - start));
start = gst_get_current_time ();
gst_bus_poll (gst_element_get_bus (pipeline),
GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
GST_TIME_ARGS (end - start), buffers);
start = gst_get_current_time ();
g_object_unref (pipeline);
end = gst_get_current_time ();
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
GST_TIME_ARGS (end - start));
return 0;
}

View file

@ -1,229 +0,0 @@
;; GStreamer
;; Copyright (C) 2005 Andy Wingo <wingo at pobox.com>
;; 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 2 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, contact:
;;
;; Free Software Foundation Voice: +1-617-542-5942
;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652
;; Boston, MA 02111-1307, USA gnu@gnu.org
;;; Commentary:
;;
;; Utilities for the network clock simulator.
;;
;;; Code:
;; Init the rng.
(use-modules ((srfi srfi-1) (fold unfold)))
(define (read-bytes-from-file-as-integer f n)
(with-input-from-file f
(lambda ()
(fold (lambda (x seed) (+ x (ash seed 8)))
0
(unfold zero? (lambda (n) (char->integer (read-char))) 1- n)))))
(set! *random-state* (seed->random-state
(read-bytes-from-file-as-integer "/dev/random" 4)))
;; General utilities.
(define (iround x)
(if (inexact? x)
(inexact->exact (round x))
x))
(define (filter proc l)
(cond
((null? l) '())
((proc (car l)) (cons (car l) (filter proc (cdr l))))
(else (filter proc (cdr l)))))
(define (sum l)
(apply + l))
(define (avg . nums)
(/ (sum nums) (length nums)))
(define (sq x)
(* x x))
(define (debug str . args)
(if *debug*
(apply format (current-error-port) str args)))
(define (print-event kind x y)
(format #t "~a ~a ~a\n" kind x y))
;; Linear least squares.
;;
;; See http://mathworld.wolfram.com/LeastSquaresFitting.html
;; returns (values slope intercept r-squared)
(define (least-squares x y)
(let ((n (length x)))
(let ((xbar (apply avg x))
(ybar (apply avg y)))
(let ((sxx (- (sum (map sq x)) (* n (sq xbar))))
(syy (- (sum (map sq y)) (* n (sq ybar))))
(sxy (- (sum (map * x y)) (* n xbar ybar))))
(let ((slope (/ sxy sxx)))
(values
slope
(- ybar (* slope xbar))
(/ (sq sxy) (* sxx syy))))))))
;; Streams: lists with lazy cdrs.
(define-macro (stream-cons kar kdr)
`(cons ,kar (delay ,kdr)))
(define (stream-cdr stream)
(force (cdr stream)))
(define (stream-car stream)
(car stream))
(define (stream-null? stream)
(null? stream))
(define (stream-ref stream n)
(if (zero? n)
(stream-car stream)
(stream-ref (stream-cdr stream) (1- n))))
(define (stream->list stream n)
(let lp ((in stream) (out '()) (n n))
(if (zero? n)
(reverse! out)
(lp (stream-cdr in) (cons (stream-car in) out) (1- n)))))
(define (stream-skip stream n)
(if (zero? n)
stream
(stream-skip (stream-cdr stream) (1- n))))
(define (stream-sample stream n)
(stream-cons (stream-car stream)
(stream-sample (stream-skip stream n) n)))
(define (stream-map proc . streams)
(stream-cons (apply proc (map stream-car streams))
(apply stream-map proc (map stream-cdr streams))))
(define (arithmetic-series start step)
(stream-cons start (arithmetic-series (+ start step) step)))
(define (scale-stream stream factor)
(stream-map (lambda (t) (* t factor)) stream))
(define (stream-while pred proc . streams)
(if (apply pred (map stream-car streams))
(begin
(apply proc (map stream-car streams))
(apply stream-while pred proc (map stream-cdr streams)))))
(define (stream-of val)
(stream-cons val (stream-of val)))
(define (periodic-stream val period)
(let ((period (iround (max 1 (* *sample-frequency* period)))))
(let lp ((n 0))
(if (zero? n)
(stream-cons val (lp period))
(stream-cons #f (lp (1- n)))))))
;; Queues with a maximum length.
(define (make-q l)
(cons l (last-pair l)))
(define (q-head q)
(car q))
(define (q-tail q)
(car q))
(define (q-push q val)
(let ((tail (cons val '())))
(if (null? (q-tail q))
(make-q tail)
(let ((l (append! (q-head q) tail)))
(if (> (length (q-head q)) *window-size*)
(make-q (cdr (q-head q)))
q)))))
;; Parameters, settable via command line arguments.
(define %parameters '())
(define-macro (define-parameter name val)
(let ((str (symbol->string name)))
(or (and (eqv? (string-ref str 0) #\*)
(eqv? (string-ref str (1- (string-length str))) #\*))
(error "Invalid parameter name" name))
(let ((param (string->symbol
(substring str 1 (1- (string-length str)))))
(val-sym (gensym)))
`(begin
(define ,name #f)
(let ((,val-sym ,val))
(set! ,name ,val-sym)
(set! %parameters (cons (cons ',param ,val-sym)
%parameters)))))))
(define (set-parameter! name val)
(define (symbol-append . args)
(string->symbol (apply string-append (map symbol->string args))))
(or (assq name %parameters)
(error "Unknown parameter" name))
(module-set! (current-module) (symbol-append '* name '*) val))
(define (parse-parameter-arguments args)
(define (usage)
(format #t "Usage: ~a ARG1...\n\n" "network-clock.scm")
(for-each
(lambda (pair)
(format #t "\t--~a=VAL \t(default: ~a)\n" (car pair) (cdr pair)))
%parameters))
(define (unknown-arg arg)
(with-output-to-port (current-error-port)
(lambda ()
(format #t "\nUnknown argument: ~a\n\n" arg)
(usage)
(quit))))
(define (parse-arguments args)
(let lp ((in args) (out '()))
(cond
((null? in)
(reverse! out))
((not (string=? (substring (car in) 0 2) "--"))
(unknown-arg (car in)))
(else
(let ((divider (or (string-index (car in) #\=)
(unknown-arg (car in)))))
(or (> divider 2) (unknown-arg (car in)))
(let ((param (string->symbol (substring (car in) 2 divider)))
(val (with-input-from-string (substring (car in) (1+ divider))
read)))
(lp (cdr in) (acons param val out))))))))
(for-each
(lambda (pair)
(or (false-if-exception
(set-parameter! (car pair) (cdr pair)))
(unknown-arg (format #f "--~a=~a" (car pair) (cdr pair)))))
(parse-arguments args)))

View file

@ -1,205 +0,0 @@
#!/bin/bash
# -*- scheme -*-
exec guile --debug -l $0 -e main -- "$@"
!#
;; GStreamer
;; Copyright (C) 2005 Andy Wingo <wingo at pobox.com>
;; 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 2 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, contact:
;;
;; Free Software Foundation Voice: +1-617-542-5942
;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652
;; Boston, MA 02111-1307, USA gnu@gnu.org
;;; Commentary:
;;
;; Network clock simulator.
;;
;; Simulates the attempts of one clock to synchronize with another over
;; the network. Packets are sent out with a local timestamp, and come
;; back with the remote time added on to the packet. The remote time is
;; assumed to have been observed at the local time in between sending
;; the query and receiving the reply.
;;
;; The local clock will attempt to adjust its rate and offset by fitting
;; a line to the last N datapoints on hand, by default 32. A better fit,
;; as measured by the correlation coefficient, will result in a longer
;; time before the next query. Bad fits or a not-yet-full set of data
;; will result in many queries in quick succession.
;;
;; The rate and offset are set directly to the slope and intercept from
;; the linear regression. This results in discontinuities in the local
;; time. As clock times must be monotonically increasing, a jump down in
;; time will result instead in time standing still for a while. Smoothly
;; varying the rate such that no discontinuities are present has not
;; been investigated.
;;
;; Implementation-wise, this simulator processes events and calculates
;; times discretely. Times are represented as streams, also known as
;; lazy lists. This is an almost-pure functional simulator. The thing to
;; remember while reading is that stream-cons does not evaluate its
;; second argument, rather deferring that calculation until stream-cdr
;; is called. In that way all times are actually infinite series.
;;
;; Usage: See network-clock.scm --help.
;;
;;; Code:
(use-modules (ice-9 popen))
(load "network-clock-utils.scm")
(define (time->samples t)
(iround (* t *sample-frequency*)))
(define (schedule-event events e time)
(let lp ((response-time (time->samples time))
(stream events))
(if (zero? response-time)
(if (not (stream-car stream))
(stream-cons e (stream-cdr stream))
(stream-cons (stream-car stream) (lp 0 (stream-cdr stream))))
(stream-cons (stream-car stream) (lp (1- response-time) (stream-cdr stream))))))
(define (schedule-send-time-query events time)
(schedule-event events (list 'send-time-query) time))
(define (schedule-time-query events l)
(schedule-event events (list 'time-query l)
(+ *send-delay* (random *send-jitter*))))
(define (schedule-time-response events l r)
(schedule-event events (list 'time-response l r)
(+ *recv-delay* (random *recv-jitter*))))
(define (network-time remote-time local-time events m b x y t)
(let ((r (stream-car remote-time))
(l (stream-car local-time))
(event (stream-car events))
(events (stream-cdr events)))
(define (next events m b x y t)
(stream-cons
(+ (* m l) b)
(network-time
(stream-cdr remote-time) (stream-cdr local-time) events m b x y t)))
(case (and=> event car)
((send-time-query)
(cond
((< (random 1.0) *packet-loss*)
(debug "; dropped time query: ~a\n" l)
(print-event 'packet-lost l (+ (* m l) b))
(next events m b x y (time->samples *timeout*)))
(else
(debug "; sending time query: ~a\n" l)
(print-event 'packet-sent l (+ (* m l) b))
(next (schedule-time-query events l) m b x y (time->samples *timeout*)))))
((time-query)
(debug "; time query received, replying with ~a\n" r)
(next (schedule-time-response events (cadr event) r) m b x y (and t (1- t))))
((time-response)
(let ((x (q-push x (avg (cadr event) l)))
(y (q-push y (caddr event))))
(call-with-values
(lambda () (least-squares (q-head x) (q-head y)))
(lambda (m b r-squared)
(define (next-time)
(max
(if (< (length (q-head x)) *window-size*)
0
(/ 1 (- 1 (min r-squared 0.99999)) 1000))
0.10))
(debug "; new slope and offset: ~a ~a (~a)\n" m b r-squared)
(print-event 'packet-observed (avg (cadr event) l) (caddr event))
(print-event 'packet-received l (+ (* m l) b))
(next (schedule-send-time-query events (next-time)) m b x y #f)))))
(else
(cond
((not t)
;; not waiting for a response
(next events m b x y t))
((<= t 0)
;; we timed out
(next (schedule-send-time-query events 0.0) m b x y 0))
(else
(next events m b x y (1- t))))))))
(define (run-simulation remote-speed local-speed)
(let ((absolute-time (arithmetic-series 0.0 (/ 1.0 *sample-frequency*)))
(event-stream (stream-of #f)))
(let ((remote-time (scale-stream absolute-time remote-speed))
(local-time (scale-stream absolute-time local-speed)))
(values
absolute-time
remote-time
local-time
(network-time
remote-time
local-time
(schedule-send-time-query event-stream 0.0)
1.0
(stream-car local-time)
(make-q (list (stream-car local-time)))
(make-q (list (stream-car remote-time)))
#f)))))
(define (print-simulation)
(display "Absolute time; Remote time; Local time; Network time\n")
(call-with-values
(lambda () (run-simulation *remote-rate* *local-rate*))
(lambda streams
(apply
stream-while
(lambda (a r l n) (<= a *total-time*))
(lambda (a r l n) (format #t "~a ~a ~a ~a\n" a r l n))
streams))))
(define (plot-simulation)
(let ((port (open-output-pipe "./plot-data Network Clock Simulation")))
(with-output-to-port port
print-simulation)
(close-pipe port)))
(define-parameter *sample-frequency* 40)
(define-parameter *send-delay* 0.1)
(define-parameter *recv-delay* 0.1)
(define-parameter *packet-loss* 0.01)
(define-parameter *send-jitter* 0.1)
(define-parameter *recv-jitter* 0.1)
(define-parameter *window-size* 32)
(define-parameter *local-rate* 1.0)
(define-parameter *remote-rate* 1.1)
(define-parameter *total-time* 5.0)
(define-parameter *timeout* 1.0)
(define-parameter *debug* #f)
(define-parameter *with-graph* #t)
(define (main args)
(parse-parameter-arguments (cdr args))
(if *with-graph*
(plot-simulation)
(print-simulation))
(quit))

View file

@ -1,81 +0,0 @@
#!/usr/bin/env python
from __future__ import division
import pylab
import optparse
import sys
def parse_data(l, state):
state['data'].append([float(x) for x in filter(None, l.split(' '))])
return state
def parse_event(l, state):
components = filter(None, l.split(' '))
vals = [float(x) for x in components[1:]]
if not components[0] in state:
state[components[0]] = [vals]
else:
state[components[0]].append(vals)
return state
def read_line(fd, state):
l = fd.readline()
if not l:
return None
l = l.strip()
if l[0].isdigit():
return parse_data(l, state)
else:
return parse_event(l, state)
def read_data(fd):
state = {'data':[],
'packet-sent':[],
'packet-lost':[],
'packet-received':[],
'packet-observed':[]}
newstate = state
while newstate:
state = newstate
newstate = read_line(fd, state)
return state
def make_xticks(start, end, numticks):
return range(int(start), int(end), int((start-end)/numticks))
def make_plot(title):
l = sys.stdin.readline()
labels = l.strip().split(';')
state = read_data(sys.stdin)
data = state['data']
lost_packets = state['packet-lost']
obsv_packets = state['packet-observed']
sent_packets = state['packet-sent']
recd_packets = state['packet-received']
domain = [x[0] for x in data]
for i in range(1,len(labels)):
pylab.plot(domain, [x[i] for x in data], label=labels[i])
pylab.plot([x[0] for x in lost_packets], [x[1] for x in lost_packets],
label='Client sent packet, but dropped', marker='x', linestyle=None, ms=8)
pylab.plot([x[0] for x in sent_packets], [x[1] for x in sent_packets],
label='Client sent packet', marker='^', linestyle=None, ms=8)
pylab.plot([x[0] for x in obsv_packets], [x[1] for x in obsv_packets],
label='Remote time observation', marker='D', linestyle=None, ms=8)
pylab.plot([x[0] for x in recd_packets], [x[1] for x in recd_packets],
label='Client received packet', marker='v', linestyle=None, ms=8)
pylab.legend()
pylab.ylabel(r'Clock time (s)')
pylab.xlabel(r'Real time (s)')
pylab.title(title)
pylab.grid(True)
pylab.show()
def main(args):
parser = optparse.OptionParser()
title = ' '.join(args[1:])
make_plot(title)
main(sys.argv)

View file

@ -1,18 +0,0 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
runxml
log.txt
dynamic-pipeline
interrupt1
interrupt2
interrupt3
sched-stress
*.bb
*.bbg
*.da

View file

@ -1,12 +0,0 @@
if GST_DISABLE_LOADSAVE
noinst_PROGRAMS =
else
noinst_PROGRAMS = runxml dynamic-pipeline sched-stress interrupt1 interrupt2 interrupt3 sort
endif
dynamic_pipeline_SOURCES = dynamic-pipeline.c
sched_stress_SOURCES = sched-stress.c
sched_stress_LDADD = $(GST_OBJ_LIBS) #-lefence
LDADD = $(GST_OBJ_LIBS)
AM_CFLAGS = $(GST_OBJ_CFLAGS)

View file

@ -1,79 +0,0 @@
<?xml version="1.0"?>
<GST-Pipeline>
<element>
<name>new_element</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin2</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
</GST-Pipeline>

View file

@ -1,235 +0,0 @@
<?xml version="1.0"?>
<GST-Pipeline>
<element>
<name>bin1</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin2</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin3</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin4</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
</GST-Pipeline>

View file

@ -1,627 +0,0 @@
<?xml version="1.0"?>
<GST-Pipeline>
<element>
<name>bin1</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity2.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity2.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity2</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin2</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin3</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>bin4</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>thread1</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>thread2</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>thread3</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>false</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>thread4</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
<value>1</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
</GST-Pipeline>

View file

@ -1,107 +0,0 @@
<?xml version="1.0"?>
<GST-Pipeline>
<element>
<name>new_element</name>
<type>bin</type>
<version>0.9.2</version>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>thread</name>
<type>thread</type>
<version>0.9.2</version>
<arg>
<name>GstThread::create_thread</name>
<value>true</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
<children>
<element>
<name>identity</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>queue.src</peer>
</pad>
<pad>
<name>src</name>
<peer>fakesink.sink</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesink</name>
<type>fakesink</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
<element>
<name>queue</name>
<type>queue</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
</pad>
<arg>
<name>GstQueue::level</name>
<value>0</value>
</arg>
<arg>
<name>GstQueue::max_level</name>
<value>20</value>
</arg>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>fakesrc</name>
<type>fakesrc</type>
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>fakesrc.src</peer>
</pad>
<pad>
<name>src</name>
<peer>queue.sink</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
</children>
</element>
</GST-Pipeline>

View file

@ -1,64 +0,0 @@
#include <gst/gst.h>
/* This test will fail because it tries to allocate two cothread_context's in
* one thread. This will cause a segfault. This is a problem with gstreamer's
* cothreading that is fixed in the newer cothreads package.
*/
int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink1, *fakesink2, *pipe1, *pipe2;
gst_init (&argc, &argv);
if (argc != 1) {
g_print ("usage: %s\n", argv[0]);
exit (-1);
}
fakesrc = gst_element_factory_make ("fakesrc", "fakesrc");
fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
/* a crucial part of this test (and one that the old cothreads fails on) is
having two active pipelines in the same thread. */
pipe1 = gst_pipeline_new ("pipe1");
pipe2 = gst_pipeline_new ("pipe2");
/* make the first pipeline */
gst_bin_add (GST_BIN (pipe1), fakesrc);
gst_bin_add (GST_BIN (pipe1), fakesink1);
gst_element_link_pads (fakesrc, "src", fakesink1, "sink");
/* initialize cothreads */
gst_element_set_state (pipe1, GST_STATE_PLAYING);
gst_element_set_state (pipe1, GST_STATE_READY);
/* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */
gst_element_unlink_pads (fakesrc, "src", fakesink1, "sink");
gst_object_ref (fakesrc);
gst_bin_remove (GST_BIN (pipe1), fakesrc);
g_usleep (2 * G_USEC_PER_SEC);
gst_bin_remove (GST_BIN (pipe1), fakesink1);
gst_object_unref (pipe1);
/* make a new pipeline */
gst_bin_add (GST_BIN (pipe2), fakesink2);
/* don't change the new pipeline's state, it should change on the bin_add */
gst_bin_add (GST_BIN (pipe2), fakesrc);
gst_element_link_pads (fakesrc, "src", fakesink2, "sink");
/* show the pipeline state */
gst_xml_write_file (GST_ELEMENT (pipe2), stdout);
/* try to iterate the pipeline */
gst_element_set_state (pipe2, GST_STATE_PLAYING);
g_usleep (2 * G_USEC_PER_SEC);
gst_element_set_state (pipe2, GST_STATE_NULL);
return 0;
}

View file

@ -1,35 +0,0 @@
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline, *queue, *src, *sink;
gst_init (&argc, &argv);
free (malloc (8)); /* -lefence */
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "src");
queue = gst_element_factory_make ("queue", "queue");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), queue);
gst_bin_add (GST_BIN (pipeline), sink);
gst_element_link_pads (src, "src", queue, "sink");
gst_element_link_pads (queue, "src", sink, "sink");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
return 0;
}

View file

@ -1,38 +0,0 @@
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline, *queue, *src, *identity, *sink;
gst_init (&argc, &argv);
free (malloc (8)); /* -lefence */
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "src");
queue = gst_element_factory_make ("queue", "queue");
identity = gst_element_factory_make ("identity", "identity");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), queue);
gst_bin_add (GST_BIN (pipeline), identity);
gst_bin_add (GST_BIN (pipeline), sink);
gst_element_link_pads (src, "src", queue, "sink");
gst_element_link_pads (queue, "src", identity, "sink");
gst_element_link_pads (identity, "src", sink, "sink");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
return 0;
}

View file

@ -1,42 +0,0 @@
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline, *queue, *src, *adder, *sink;
GstPad *sinkpad;
gst_init (&argc, &argv);
free (malloc (8)); /* -lefence */
pipeline = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "src");
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
queue = gst_element_factory_make ("queue", "queue");
adder = gst_element_factory_make ("adder", "adder");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (pipeline), src);
gst_bin_add (GST_BIN (pipeline), queue);
gst_bin_add (GST_BIN (pipeline), adder);
gst_bin_add (GST_BIN (pipeline), sink);
sinkpad = gst_element_get_request_pad (adder, "sink%d");
gst_element_link_pads (src, "src", queue, "sink");
gst_pad_link (gst_element_get_pad (queue, "src"), sinkpad);
gst_element_link_pads (adder, "src", sink, "sink");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
return 0;
}

View file

@ -1,15 +0,0 @@
#/bin/bash
echo "log" > log.txt
for i in cases/*.xml
do
./runxml $i
error=$?
if test $error -ne 0;
then
echo $i " error," $error >>log.txt
else
echo $i " ok" >>log.txt
fi
done

View file

@ -1,90 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static guint outcount, incount;
static void
buffer_handoff_sink (GstElement * src, GstBuffer * buf, GstElement * bin)
{
g_print ("\n\n *** buffer arrived in sink ***\n\n");
gst_element_set_state (bin, GST_STATE_NULL);
outcount++;
}
static void
buffer_handoff_src (GstElement * src, GstBuffer * buf, GstElement * bin)
{
g_print ("\n\n *** buffer started in src ***\n\n");
incount++;
}
/* eos will be called when the src element has an end of stream */
void
eos (GstElement * element, gpointer data)
{
g_print ("have eos, quitting\n");
}
int
main (int argc, char *argv[])
{
GstXML *xml;
GList *toplevelelements;
gint i = 1;
gst_init (&argc, &argv);
if (argc < 2) {
g_print ("usage: %s <xml file>\n", argv[0]);
exit (-1);
}
g_print ("\n *** using testfile %s\n", argv[1]);
xml = gst_xml_new ();
gst_xml_parse_file (xml, (const guchar *) argv[1], NULL);
toplevelelements = gst_xml_get_topelements (xml);
while (toplevelelements) {
GstElement *bin = (GstElement *) toplevelelements->data;
GstElement *src, *sink;
g_print ("\n ***** testcase %d\n", i++);
src = gst_bin_get_by_name (GST_BIN (bin), "fakesrc");
if (src) {
g_signal_connect (G_OBJECT (src), "handoff",
G_CALLBACK (buffer_handoff_src), bin);
} else {
g_print ("could not find src element\n");
exit (-1);
}
sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink");
if (sink) {
g_signal_connect (G_OBJECT (sink), "handoff",
G_CALLBACK (buffer_handoff_sink), bin);
} else {
g_print ("could not find sink element\n");
exit (-1);
}
incount = 0;
outcount = 0;
/* gst_element_set_state(bin, GST_STATE_READY); */
gst_element_set_state (bin, GST_STATE_PLAYING);
if (outcount != 1 && incount != 1) {
g_print ("test failed\n");
exit (-1);
}
toplevelelements = g_list_next (toplevelelements);
}
exit (0);
}

View file

@ -1,27 +0,0 @@
#include <gst/gst.h>
#define TAILLE 100
int
main (int argc, char *argv[])
{
GstElement *bin, *src, *dec, *sink;
int i;
gst_init (&argc, &argv);
free (malloc (8)); /* -lefence */
for (i = 0; i < TAILLE; i++) {
bin = gst_pipeline_new ("pipeline");
src = gst_element_factory_make ("fakesrc", "source");
dec = gst_element_factory_make ("identity", "decoder");
sink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add_many (GST_BIN (bin), src, dec, sink, NULL);
gst_element_link_many (src, dec, sink, NULL);
gst_element_set_state (bin, GST_STATE_PLAYING);
gst_element_set_state (bin, GST_STATE_PAUSED);
}
return 0;
}

View file

@ -1,160 +0,0 @@
#include <gst/gst.h>
static GstElement *
make_pipeline1 ()
{
GstElement *fakesrc, *fakesink;
GstElement *pipeline;
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
gst_element_link (fakesrc, fakesink);
return pipeline;
}
static GstElement *
make_pipeline2 ()
{
GstElement *fakesrc, *tee, *fakesink1, *fakesink2;
GstElement *pipeline;
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
tee = gst_element_factory_make ("tee", "tee");
g_assert (tee != NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fake_sink1");
g_assert (fakesink1 != NULL);
fakesink2 = gst_element_factory_make ("fakesink", "fake_sink2");
g_assert (fakesink2 != NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, tee, fakesink1, fakesink2,
NULL);
gst_element_link (fakesrc, tee);
gst_element_link (tee, fakesink1);
gst_element_link (tee, fakesink2);
return pipeline;
}
static GstElement *
make_pipeline3 ()
{
GstElement *fakesrc, *tee, *identity, *fakesink1, *fakesink2;
GstElement *pipeline;
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
tee = gst_element_factory_make ("tee", "tee");
g_assert (tee != NULL);
identity = gst_element_factory_make ("identity", "identity");
g_assert (identity != NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fake_sink1");
g_assert (fakesink1 != NULL);
fakesink2 = gst_element_factory_make ("fakesink", "fake_sink2");
g_assert (fakesink2 != NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, tee, identity,
fakesink1, fakesink2, NULL);
gst_element_link (fakesrc, tee);
gst_element_link (tee, identity);
gst_element_link (identity, fakesink1);
gst_element_link (tee, fakesink2);
return pipeline;
}
static GstElement *
make_pipeline4 ()
{
GstElement *fakesrc, *tee, *identity, *fakesink1, *fakesink2;
GstElement *pipeline;
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
tee = gst_element_factory_make ("tee", "tee");
g_assert (tee != NULL);
identity = gst_element_factory_make ("identity", "identity");
g_assert (identity != NULL);
fakesink1 = gst_element_factory_make ("fakesink", "fake_sink1");
g_assert (fakesink1 != NULL);
fakesink2 = gst_element_factory_make ("fakesink", "fake_sink2");
g_assert (fakesink2 != NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, tee, identity,
fakesink1, fakesink2, NULL);
gst_element_link (fakesrc, tee);
gst_element_link (identity, fakesink1);
return pipeline;
}
static void
print_elem (GstElement * elem, gpointer unused)
{
g_print ("----> %s\n", GST_ELEMENT_NAME (elem));
gst_object_unref (elem);
}
int
main (int argc, gchar * argv[])
{
GstElement *bin;
GstIterator *it;
gst_init (&argc, &argv);
g_print ("pipeline 1\n");
bin = make_pipeline1 ();
it = gst_bin_iterate_sorted (GST_BIN (bin));
gst_iterator_foreach (it, (GFunc) print_elem, NULL);
gst_iterator_free (it);
g_print ("pipeline 2\n");
bin = make_pipeline2 ();
it = gst_bin_iterate_sorted (GST_BIN (bin));
gst_iterator_foreach (it, (GFunc) print_elem, NULL);
gst_iterator_free (it);
g_print ("pipeline 3\n");
bin = make_pipeline3 ();
it = gst_bin_iterate_sorted (GST_BIN (bin));
gst_iterator_foreach (it, (GFunc) print_elem, NULL);
gst_iterator_free (it);
g_print ("pipeline 4\n");
bin = make_pipeline4 ();
it = gst_bin_iterate_sorted (GST_BIN (bin));
gst_iterator_foreach (it, (GFunc) print_elem, NULL);
gst_iterator_free (it);
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -1,18 +0,0 @@
tcN: fakesrc-fakesink
tcP: fakesrc ! fakesink
tcS: A, fakesrc0, handoff
tcS: B, fakesink0, handoff
tcI: 2
tcT: 2000
tcR: A,1,B,1,A,1,B,1
tcN: fakesrc-identity-fakesink
tcP: fakesrc ! identity ! fakesink
tcS: A, fakesrc0, handoff
tcS: B, identity, handoff
tcS: C, fakesink0, handoff
tcI: 2
tcT: 2000
tcR: A,1,B,1,C,1,A,1,B,1,C,1

View file

@ -1,12 +0,0 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
seeking1
*.bb
*.bbg
*.da

View file

@ -1,4 +0,0 @@
noinst_PROGRAMS = seeking1
LDADD = $(GST_OBJ_LIBS)
AM_CFLAGS = $(GST_OBJ_CFLAGS)

View file

@ -1,104 +0,0 @@
#include <gst/gst.h>
static gint looping;
static GstEvent *event;
static GstPad *pad;
static void
event_received (GObject * object, GstEvent * event, GstElement * pipeline)
{
#if 0
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT_DONE) {
g_print ("segment done\n");
if (--looping == 1) {
event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 20, 25);
} else {
event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55);
}
gst_pad_send_event (pad, event);
}
#endif
}
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *fakesrc;
GstElement *fakesink;
/* guint64 value; */
GstFormat format;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
fakesrc = gst_element_factory_make ("fakesrc", "src");
fakesink = gst_element_factory_make ("fakesink", "sink");
gst_bin_add (GST_BIN (pipeline), fakesrc);
gst_bin_add (GST_BIN (pipeline), fakesink);
gst_element_link_pads (fakesrc, "src", fakesink, "sink");
gst_element_set_state (pipeline, GST_STATE_READY);
pad = gst_element_get_pad (fakesrc, "src");
g_print ("doing segment seek from 5 to 10\n");
gst_pad_send_event (pad,
gst_event_new_seek (1.0, GST_FORMAT_DEFAULT,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT,
GST_SEEK_TYPE_SET, 5, GST_SEEK_TYPE_SET, 10));
format = GST_FORMAT_DEFAULT;
#if 0
gst_pad_query (pad, GST_QUERY_START, &format, &value);
g_print ("configured for start %" G_GINT64_FORMAT "\n", value);
gst_pad_query (pad, GST_QUERY_SEGMENT_END, &format, &value);
g_print ("configured segment end %" G_GINT64_FORMAT "\n", value);
#endif
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_object_default_deep_notify), NULL);
g_usleep (2 * G_USEC_PER_SEC);
g_print
("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n");
looping = 3;
event =
gst_event_new_seek (1.0, GST_FORMAT_DEFAULT,
GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT,
GST_SEEK_TYPE_SET, 50, GST_SEEK_TYPE_SET, 55);
gst_pad_send_event (pad, event);
g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")),
"event_received", G_CALLBACK (event_received), event);
#if 0
gst_pad_query (pad, GST_QUERY_START, &format, &value);
g_print ("configured for start %" G_GINT64_FORMAT "\n", value);
gst_pad_query (pad, GST_QUERY_SEGMENT_END, &format, &value);
g_print ("configured segment end %" G_GINT64_FORMAT "\n", value);
#endif
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (2 * G_USEC_PER_SEC);
gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;
}

View file

@ -1,18 +0,0 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
test1
test2
threadstate1
threadstate2
threadstate3
threadstate4
threadstate5
*.bb
*.bbg
*.da

View file

@ -1,4 +0,0 @@
noinst_PROGRAMS = threadstate1 threadstate2 threadstate3 threadstate4 threadstate5 test1 test2
LDADD = $(GST_OBJ_LIBS)
AM_CFLAGS = $(GST_OBJ_CFLAGS)

View file

@ -1,104 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <glib.h>
typedef struct
{
GMutex *mutex;
GCond *cond;
gint var;
} ThreadInfo;
static void *
thread_loop (void *arg)
{
ThreadInfo *info = (ThreadInfo *) arg;
g_print ("thread: entering %p\n", info);
g_print ("thread: lock\n");
g_mutex_lock (info->mutex);
g_print ("thread: signal spinup\n");
g_cond_signal (info->cond);
g_print ("thread: wait ACK\n");
g_cond_wait (info->cond, info->mutex);
info->var = 1;
g_print ("thread: signal var change\n");
g_cond_signal (info->cond);
g_print ("thread: unlock\n");
g_mutex_unlock (info->mutex);
g_print ("thread: exit\n");
return NULL;
}
gint
main (gint argc, gchar * argv[])
{
ThreadInfo *info;
GThread *thread;
GError *error = NULL;
gint res = 0;
if (!g_thread_supported ())
g_thread_init (NULL);
info = g_new (ThreadInfo, 1);
info->mutex = g_mutex_new ();
info->cond = g_cond_new ();
info->var = 0;
g_print ("main: lock\n");
g_mutex_lock (info->mutex);
thread = g_thread_create (thread_loop, info, TRUE, &error);
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_error_free (error);
res = -1;
goto done;
}
g_print ("main: wait spinup\n");
g_cond_wait (info->cond, info->mutex);
g_print ("main: signal ACK\n");
g_cond_signal (info->cond);
g_print ("main: waiting for thread to change var\n");
g_cond_wait (info->cond, info->mutex);
g_print ("main: var == %d\n", info->var);
if (info->var != 1)
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
g_mutex_unlock (info->mutex);
g_print ("main: join\n");
g_thread_join (thread);
done:
g_mutex_free (info->mutex);
g_cond_free (info->cond);
g_free (info);
return res;
}

View file

@ -1,108 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <glib.h>
typedef struct
{
GMutex *mutex;
GCond *cond_t;
GCond *cond_p;
gint var;
} ThreadInfo;
static void *
thread_loop (void *arg)
{
ThreadInfo *info = (ThreadInfo *) arg;
g_print ("thread: entering %p\n", info);
g_print ("thread: lock\n");
g_mutex_lock (info->mutex);
g_print ("thread: signal spinup\n");
g_cond_signal (info->cond_t);
g_print ("thread: wait ACK\n");
g_cond_wait (info->cond_p, info->mutex);
info->var = 1;
g_print ("thread: signal var change\n");
g_cond_signal (info->cond_t);
g_print ("thread: unlock\n");
g_mutex_unlock (info->mutex);
g_print ("thread: exit\n");
return NULL;
}
gint
main (gint argc, gchar * argv[])
{
ThreadInfo *info;
GThread *thread;
GError *error = NULL;
gint res = 0;
if (!g_thread_supported ())
g_thread_init (NULL);
info = g_new (ThreadInfo, 1);
info->mutex = g_mutex_new ();
info->cond_t = g_cond_new ();
info->cond_p = g_cond_new ();
info->var = 0;
g_print ("main: lock\n");
g_mutex_lock (info->mutex);
thread = g_thread_create (thread_loop, info, TRUE, &error);
if (error != NULL) {
g_print ("Unable to start thread: %s\n", error->message);
g_error_free (error);
res = -1;
goto done;
}
g_print ("main: wait spinup\n");
g_cond_wait (info->cond_t, info->mutex);
g_print ("main: signal ACK\n");
g_cond_signal (info->cond_p);
g_print ("main: waiting for thread to change var\n");
g_cond_wait (info->cond_t, info->mutex);
g_print ("main: var == %d\n", info->var);
if (info->var != 1) {
g_print ("main: !!error!! expected var == 1, got %d\n", info->var);
}
g_mutex_unlock (info->mutex);
g_print ("main: join\n");
g_thread_join (thread);
done:
g_mutex_free (info->mutex);
g_cond_free (info->cond_t);
g_cond_free (info->cond_p);
g_free (info);
return res;
}

View file

@ -1,41 +0,0 @@
#include <stdlib.h>
#include <gst/gst.h>
/* this pipeline is:
* { fakesrc ! fakesink }
*/
int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *pipeline;
gint x;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL);
gst_element_link (fakesrc, fakesink);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("pausing %d\n", x);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
g_usleep (G_USEC_PER_SEC);
}
exit (0);
}

View file

@ -1,90 +0,0 @@
#include <stdlib.h>
#include <gst/gst.h>
static GMainLoop *loop;
static gboolean EOS = FALSE;
/* this pipeline is:
* { filesrc ! mad ! osssink }
*/
static gboolean
bus_handler (GstBus * bus, GstMessage * message, gpointer data)
{
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_EOS:
g_print ("have eos, quitting\n");
EOS = TRUE;
if (g_main_loop_is_running (loop))
g_main_loop_quit (loop);
break;
default:
break;
}
return TRUE;
}
static gboolean
timeout_func (GMainLoop * loop)
{
g_main_loop_quit (loop);
return TRUE;
}
int
main (int argc, char *argv[])
{
GstElement *filesrc, *osssink;
GstElement *pipeline;
GstElement *mad;
gint x;
GstBus *bus;
gst_init (&argc, &argv);
if (argc != 2) {
g_print ("usage: %s <filename>\n", argv[0]);
exit (-1);
}
/* create a new pipeline to hold the elements */
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
/* create a disk reader */
filesrc = gst_element_factory_make ("filesrc", "disk_source");
g_assert (filesrc != NULL);
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
/* and an audio sink */
osssink = gst_element_factory_make ("osssink", "play_audio");
g_assert (osssink != NULL);
/* did i mention that this is an mp3 player? */
mad = gst_element_factory_make ("mad", "mp3_decoder");
g_assert (mad != NULL);
gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, osssink, NULL);
gst_element_link_many (filesrc, mad, osssink, NULL);
loop = g_main_loop_new (NULL, FALSE);
g_timeout_add (2 * 1000, (GSourceFunc) timeout_func, loop);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, GST_MESSAGE_ANY, (GstBusFunc) bus_handler, pipeline);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
g_main_loop_run (loop);
if (EOS)
break;
g_print ("pausing %d\n", x);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);
g_main_loop_run (loop);
}
exit (0);
}

View file

@ -1,44 +0,0 @@
#include <stdlib.h>
#include <gst/gst.h>
/* this pipeline is:
* { { fakesrc ! fakesink } }
*/
int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *pipeline, *pipeline2;
gint x;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
pipeline2 = gst_pipeline_new ("pipeline2");
g_assert (pipeline2 != NULL);
gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (pipeline2));
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (pipeline2), fakesrc, fakesink, NULL);
gst_element_link (fakesrc, fakesink);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("nulling %d\n", x);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
exit (0);
}

View file

@ -1,52 +0,0 @@
#include <stdlib.h>
#include <gst/gst.h>
/* this pipeline is:
* { { fakesrc } ! queue ! fakesink }
*/
int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *pipeline, *pipeline2;
GstElement *queue;
gint x;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
pipeline2 = gst_pipeline_new ("pipeline");
g_assert (pipeline2 != NULL);
queue = gst_element_factory_make ("queue", "the_queue");
g_assert (queue != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (pipeline), pipeline2, queue, fakesink, NULL);
gst_bin_add (GST_BIN (pipeline2), fakesrc);
gst_element_add_pad (pipeline2, gst_ghost_pad_new ("src",
gst_element_get_pad (fakesrc, "src")));
gst_element_link_many (pipeline2, queue, fakesink, NULL);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("nulling %d\n", x);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
exit (0);
}

View file

@ -1,52 +0,0 @@
#include <stdlib.h>
#include <gst/gst.h>
/* this pipeline is:
* { fakesrc ! { queue ! fakesink } }
*/
int
main (int argc, char *argv[])
{
GstElement *fakesrc, *fakesink;
GstElement *pipeline, *pipeline2;
GstElement *queue;
gint x;
gst_init (&argc, &argv);
pipeline = gst_pipeline_new ("pipeline");
g_assert (pipeline != NULL);
pipeline2 = gst_pipeline_new ("pipeline");
g_assert (pipeline2 != NULL);
queue = gst_element_factory_make ("queue", "the_queue");
g_assert (queue != NULL);
fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
g_assert (fakesrc != NULL);
fakesink = gst_element_factory_make ("fakesink", "fake_sink");
g_assert (fakesink != NULL);
gst_bin_add_many (GST_BIN (pipeline), fakesrc, pipeline2, NULL);
gst_bin_add_many (GST_BIN (pipeline2), queue, fakesink, NULL);
gst_element_add_pad (pipeline2, gst_ghost_pad_new ("sink",
gst_element_get_pad (queue, "sink")));
gst_element_link_many (queue, fakesink, NULL);
gst_element_link_many (fakesrc, pipeline2, NULL);
for (x = 0; x < 10; x++) {
g_print ("playing %d\n", x);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_usleep (G_USEC_PER_SEC);
g_print ("nulling %d\n", x);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_usleep (G_USEC_PER_SEC);
}
exit (0);
}