summaryrefslogtreecommitdiff
path: root/swfdec/swfdec_stream_target.c
blob: a7799d50e33ef26d51834aa5a59fa894f48a65c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* Swfdec
 * Copyright (C) 2007-2008 Benjamin Otte <otte@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "swfdec_stream_target.h"
#include "swfdec_debug.h"
#include "swfdec_loader_internal.h"
#include "swfdec_player_internal.h"

static void
swfdec_stream_target_base_init (gpointer g_class)
{
  static gboolean initialized = FALSE;

  if (G_UNLIKELY (!initialized)) {
    initialized = TRUE;
  }
}

GType
swfdec_stream_target_get_type (void)
{
  static GType stream_target_type = 0;
  
  if (!stream_target_type) {
    static const GTypeInfo stream_target_info = {
      sizeof (SwfdecStreamTargetInterface),
      swfdec_stream_target_base_init,
      NULL,
      NULL,
      NULL,
      NULL,
      0,
      0,
      NULL,
    };
    
    stream_target_type = g_type_register_static (G_TYPE_INTERFACE,
        "SwfdecStreamTarget", &stream_target_info, 0);
    g_type_interface_add_prerequisite (stream_target_type, G_TYPE_OBJECT);
  }
  
  return stream_target_type;
}

SwfdecPlayer *
swfdec_stream_target_get_player (SwfdecStreamTarget *target)
{
  SwfdecStreamTargetInterface *iface;
  
  g_return_val_if_fail (SWFDEC_IS_STREAM_TARGET (target), NULL);

  iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
  g_assert (iface->get_player != NULL);
  return iface->get_player (target);
}

void
swfdec_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *stream)
{
  SwfdecStreamTargetInterface *iface;
  
  g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
  g_return_if_fail (SWFDEC_IS_STREAM (stream));

  SWFDEC_LOG ("opening %s", swfdec_stream_describe (stream));

  iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
  if (iface->open)
    iface->open (target, stream);
}

gboolean
swfdec_stream_target_parse (SwfdecStreamTarget *target, SwfdecStream *stream)
{
  SwfdecStreamTargetInterface *iface;
  gboolean call_again;
  
  g_return_val_if_fail (SWFDEC_IS_STREAM_TARGET (target), FALSE);
  g_return_val_if_fail (SWFDEC_IS_STREAM (stream), FALSE);

  SWFDEC_LOG ("parsing %s", swfdec_stream_describe (stream));

  iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
  if (iface->parse)
    call_again = iface->parse (target, stream);
  else
    call_again = FALSE;

  return call_again;
}

void
swfdec_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *stream)
{
  SwfdecStreamTargetInterface *iface;
  
  g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
  g_return_if_fail (SWFDEC_IS_STREAM (stream));

  SWFDEC_LOG ("close on %s", swfdec_stream_describe (stream));

  iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
  if (iface->close)
    iface->close (target, stream);
}

void
swfdec_stream_target_error (SwfdecStreamTarget *target, SwfdecStream *stream)
{
  SwfdecStreamTargetInterface *iface;
  
  g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
  g_return_if_fail (SWFDEC_IS_STREAM (stream));

  SWFDEC_LOG ("error on %s", swfdec_stream_describe (stream));

  iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
  if (iface->error)
    iface->error (target, stream);
}

void
swfdec_stream_target_writable (SwfdecStreamTarget *target, SwfdecStream *stream)
{
  SwfdecStreamTargetInterface *iface;
  
  g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
  g_return_if_fail (SWFDEC_IS_STREAM (stream));

  SWFDEC_LOG ("writable on %s", swfdec_stream_describe (stream));

  iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
  if (iface->writable)
    iface->writable (target, stream);
}