~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to channels/tsmf/client/tsmf_ifman.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.1.9) (9.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20141111122050-wyr8hrnwco9fcmum
Tags: 1.1.0~git20140921.1.440916e+dfsg1-2ubuntu1
* Merge with Debian unstable, remaining changes
  - Disable ffmpeg support
* Disable gstreamer support, this relies on gstreamer 0.10 and we don't want
  to add any more deps on that.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Implementation
 
3
 * Video Redirection Virtual Channel - Interface Manipulation
 
4
 *
 
5
 * Copyright 2010-2011 Vic Lee
 
6
 * Copyright 2012 Hewlett-Packard Development Company, L.P.
 
7
 *
 
8
 * Licensed under the Apache License, Version 2.0 (the "License");
 
9
 * you may not use this file except in compliance with the License.
 
10
 * You may obtain a copy of the License at
 
11
 *
 
12
 *     http://www.apache.org/licenses/LICENSE-2.0
 
13
 *
 
14
 * Unless required by applicable law or agreed to in writing, software
 
15
 * distributed under the License is distributed on an "AS IS" BASIS,
 
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
17
 * See the License for the specific language governing permissions and
 
18
 * limitations under the License.
 
19
 */
 
20
 
 
21
#ifdef HAVE_CONFIG_H
 
22
#include "config.h"
 
23
#endif
 
24
 
 
25
#include <stdio.h>
 
26
#include <stdlib.h>
 
27
#include <string.h>
 
28
 
 
29
#include <winpr/crt.h>
 
30
 
 
31
#include <winpr/stream.h>
 
32
 
 
33
#include "tsmf_types.h"
 
34
#include "tsmf_constants.h"
 
35
#include "tsmf_media.h"
 
36
#include "tsmf_codec.h"
 
37
 
 
38
#include "tsmf_ifman.h"
 
39
 
 
40
int tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman)
 
41
{
 
42
        UINT32 CapabilityValue;
 
43
 
 
44
        Stream_Read_UINT32(ifman->input, CapabilityValue);
 
45
        DEBUG_DVC("server CapabilityValue %d", CapabilityValue);
 
46
 
 
47
        Stream_EnsureRemainingCapacity(ifman->output, 8);
 
48
        Stream_Write_UINT32(ifman->output, 1); /* CapabilityValue */
 
49
        Stream_Write_UINT32(ifman->output, 0); /* Result */
 
50
 
 
51
        return 0;
 
52
}
 
53
 
 
54
int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
 
55
{
 
56
        UINT32 i;
 
57
        UINT32 v;
 
58
        UINT32 pos;
 
59
        UINT32 CapabilityType;
 
60
        UINT32 cbCapabilityLength;
 
61
        UINT32 numHostCapabilities;
 
62
 
 
63
        pos = Stream_GetPosition(ifman->output);
 
64
        Stream_EnsureRemainingCapacity(ifman->output, ifman->input_size + 4);
 
65
        Stream_Copy(ifman->output, ifman->input, ifman->input_size);
 
66
 
 
67
        Stream_SetPosition(ifman->output, pos);
 
68
        Stream_Read_UINT32(ifman->output, numHostCapabilities);
 
69
 
 
70
        for (i = 0; i < numHostCapabilities; i++)
 
71
        {
 
72
                Stream_Read_UINT32(ifman->output, CapabilityType);
 
73
                Stream_Read_UINT32(ifman->output, cbCapabilityLength);
 
74
                pos = Stream_GetPosition(ifman->output);
 
75
 
 
76
                switch (CapabilityType)
 
77
                {
 
78
                        case 1: /* Protocol version request */
 
79
                                Stream_Read_UINT32(ifman->output, v);
 
80
                                DEBUG_DVC("server protocol version %d", v);
 
81
                                break;
 
82
                        case 2: /* Supported platform */
 
83
                                Stream_Peek_UINT32(ifman->output, v);
 
84
                                DEBUG_DVC("server supported platform %d", v);
 
85
                                /* Claim that we support both MF and DShow platforms. */
 
86
                                Stream_Write_UINT32(ifman->output,
 
87
                                        MMREDIR_CAPABILITY_PLATFORM_MF | MMREDIR_CAPABILITY_PLATFORM_DSHOW);
 
88
                                break;
 
89
                        default:
 
90
                                DEBUG_WARN("unknown capability type %d", CapabilityType);
 
91
                                break;
 
92
                }
 
93
                Stream_SetPosition(ifman->output, pos + cbCapabilityLength);
 
94
        }
 
95
        Stream_Write_UINT32(ifman->output, 0); /* Result */
 
96
 
 
97
        ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
 
98
 
 
99
        return 0;
 
100
}
 
101
 
 
102
int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman)
 
103
{
 
104
        UINT32 numMediaType;
 
105
        UINT32 PlatformCookie;
 
106
        UINT32 FormatSupported = 1;
 
107
 
 
108
        Stream_Read_UINT32(ifman->input, PlatformCookie);
 
109
        Stream_Seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */
 
110
        Stream_Read_UINT32(ifman->input, numMediaType);
 
111
 
 
112
        DEBUG_DVC("PlatformCookie %d numMediaType %d", PlatformCookie, numMediaType);
 
113
 
 
114
        if (!tsmf_codec_check_media_type(ifman->input))
 
115
                FormatSupported = 0;
 
116
 
 
117
        if (FormatSupported)
 
118
                DEBUG_DVC("format ok.");
 
119
 
 
120
        Stream_EnsureRemainingCapacity(ifman->output, 12);
 
121
        Stream_Write_UINT32(ifman->output, FormatSupported);
 
122
        Stream_Write_UINT32(ifman->output, PlatformCookie);
 
123
        Stream_Write_UINT32(ifman->output, 0); /* Result */
 
124
 
 
125
        ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
 
126
 
 
127
        return 0;
 
128
}
 
129
 
 
130
int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman)
 
131
{
 
132
        int status = 0;
 
133
        TSMF_PRESENTATION* presentation;
 
134
 
 
135
        DEBUG_DVC("");
 
136
 
 
137
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
138
        if (presentation)
 
139
        {
 
140
                DEBUG_DVC("Presentation already exists");
 
141
                ifman->output_pending = FALSE;
 
142
                return 0;
 
143
 
 
144
        }
 
145
 
 
146
        presentation = tsmf_presentation_new(Stream_Pointer(ifman->input), ifman->channel_callback);
 
147
 
 
148
        if (presentation == NULL)
 
149
                status = 1;
 
150
        else
 
151
                tsmf_presentation_set_audio_device(presentation, ifman->audio_name, ifman->audio_device);
 
152
 
 
153
        ifman->output_pending = TRUE;
 
154
 
 
155
        return status;
 
156
}
 
157
 
 
158
int tsmf_ifman_add_stream(TSMF_IFMAN* ifman)
 
159
{
 
160
        UINT32 StreamId;
 
161
        int status = 0;
 
162
        TSMF_STREAM* stream;
 
163
        TSMF_PRESENTATION* presentation;
 
164
 
 
165
        DEBUG_DVC("");
 
166
 
 
167
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
168
        Stream_Seek(ifman->input, 16);
 
169
 
 
170
        if (presentation == NULL)
 
171
        {
 
172
                status = 1;
 
173
        }
 
174
        else
 
175
        {
 
176
                Stream_Read_UINT32(ifman->input, StreamId);
 
177
                Stream_Seek_UINT32(ifman->input); /* numMediaType */
 
178
                stream = tsmf_stream_new(presentation, StreamId);
 
179
 
 
180
                if (stream)
 
181
                        tsmf_stream_set_format(stream, ifman->decoder_name, ifman->input);
 
182
        }
 
183
 
 
184
        ifman->output_pending = TRUE;
 
185
 
 
186
        return status;
 
187
}
 
188
 
 
189
int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman)
 
190
{
 
191
        DEBUG_DVC("");
 
192
 
 
193
        Stream_EnsureRemainingCapacity(ifman->output, 8);
 
194
        Stream_Write_UINT32(ifman->output, 1); /* TopologyReady */
 
195
        Stream_Write_UINT32(ifman->output, 0); /* Result */
 
196
        ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
 
197
 
 
198
        return 0;
 
199
}
 
200
 
 
201
int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman)
 
202
{
 
203
        int status = 0;
 
204
        UINT32 StreamId;
 
205
        TSMF_STREAM* stream;
 
206
        TSMF_PRESENTATION* presentation;
 
207
 
 
208
        DEBUG_DVC("");
 
209
 
 
210
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
211
        Stream_Seek(ifman->input, 16);
 
212
 
 
213
        if (presentation == NULL)
 
214
        {
 
215
                status = 1;
 
216
        }
 
217
        else
 
218
        {
 
219
                Stream_Read_UINT32(ifman->input, StreamId);
 
220
                stream = tsmf_stream_find_by_id(presentation, StreamId);
 
221
                if (stream)
 
222
                        tsmf_stream_free(stream);
 
223
                else
 
224
                        status = 1;
 
225
        }
 
226
 
 
227
        ifman->output_pending = TRUE;
 
228
 
 
229
        return status;
 
230
}
 
231
 
 
232
float tsmf_stream_read_float(wStream* s)
 
233
{
 
234
        float fValue;
 
235
        UINT32 iValue;
 
236
 
 
237
        Stream_Read_UINT32(s, iValue);
 
238
        CopyMemory(&fValue, &iValue, 4);
 
239
 
 
240
        return fValue;
 
241
}
 
242
 
 
243
int tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman)
 
244
{
 
245
        int status = 0;
 
246
        float Left, Top;
 
247
        float Right, Bottom;
 
248
        TSMF_PRESENTATION* presentation;
 
249
 
 
250
        DEBUG_DVC("");
 
251
 
 
252
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
253
        Stream_Seek(ifman->input, 16);
 
254
 
 
255
        if (!presentation)
 
256
        {
 
257
                status = 1;
 
258
        }
 
259
        else
 
260
        {
 
261
                Left = tsmf_stream_read_float(ifman->input); /* Left (4 bytes) */
 
262
                Top = tsmf_stream_read_float(ifman->input); /* Top (4 bytes) */
 
263
                Right = tsmf_stream_read_float(ifman->input); /* Right (4 bytes) */
 
264
                Bottom = tsmf_stream_read_float(ifman->input); /* Bottom (4 bytes) */
 
265
 
 
266
                DEBUG_DVC("SetSourceVideoRect: Left: %f Top: %f Right: %f Bottom: %f",
 
267
                                Left, Top, Right, Bottom);
 
268
        }
 
269
 
 
270
        ifman->output_pending = TRUE;
 
271
 
 
272
        return status;
 
273
}
 
274
 
 
275
int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman)
 
276
{
 
277
        TSMF_PRESENTATION* presentation;
 
278
 
 
279
        DEBUG_DVC("");
 
280
 
 
281
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
282
 
 
283
        if (presentation)
 
284
                tsmf_presentation_free(presentation);
 
285
        else
 
286
                DEBUG_WARN("unknown presentation id");
 
287
 
 
288
        Stream_EnsureRemainingCapacity(ifman->output, 4);
 
289
        Stream_Write_UINT32(ifman->output, 0); /* Result */
 
290
        ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
 
291
 
 
292
        return 0;
 
293
}
 
294
 
 
295
int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman)
 
296
{
 
297
        TSMF_PRESENTATION* presentation;
 
298
 
 
299
        DEBUG_DVC("on stream volume");
 
300
 
 
301
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
302
 
 
303
        if (presentation)
 
304
        {
 
305
                UINT32 newVolume;
 
306
                UINT32 muted;
 
307
 
 
308
                Stream_Seek(ifman->input, 16);
 
309
                Stream_Read_UINT32(ifman->input, newVolume);
 
310
                DEBUG_DVC("on stream volume: new volume=[%d]", newVolume);
 
311
                Stream_Read_UINT32(ifman->input, muted);
 
312
                DEBUG_DVC("on stream volume: muted=[%d]", muted);
 
313
                tsmf_presentation_volume_changed(presentation, newVolume, muted);
 
314
        }
 
315
        else
 
316
        {
 
317
                DEBUG_WARN("unknown presentation id");
 
318
        }
 
319
 
 
320
        ifman->output_pending = TRUE;
 
321
 
 
322
        return 0;
 
323
}
 
324
 
 
325
int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman)
 
326
{
 
327
        TSMF_PRESENTATION* presentation;
 
328
 
 
329
        DEBUG_DVC("on channel volume");
 
330
        
 
331
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
332
 
 
333
        if (presentation)
 
334
        {
 
335
                UINT32 channelVolume;
 
336
                UINT32 changedChannel;
 
337
 
 
338
                Stream_Seek(ifman->input, 16);
 
339
                Stream_Read_UINT32(ifman->input, channelVolume);
 
340
                DEBUG_DVC("on channel volume: channel volume=[%d]", channelVolume);
 
341
                Stream_Read_UINT32(ifman->input, changedChannel);
 
342
                DEBUG_DVC("on stream volume: changed channel=[%d]", changedChannel);
 
343
        }
 
344
        
 
345
        ifman->output_pending = TRUE;
 
346
        
 
347
        return 0;
 
348
}
 
349
 
 
350
int tsmf_ifman_set_video_window(TSMF_IFMAN* ifman)
 
351
{
 
352
        DEBUG_DVC("");
 
353
        ifman->output_pending = TRUE;
 
354
        return 0;
 
355
}
 
356
 
 
357
int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
 
358
{
 
359
        TSMF_PRESENTATION* presentation;
 
360
        UINT32 numGeometryInfo;
 
361
        UINT32 Left;
 
362
        UINT32 Top;
 
363
        UINT32 Width;
 
364
        UINT32 Height;
 
365
        UINT32 cbVisibleRect;
 
366
        RDP_RECT* rects = NULL;
 
367
        int num_rects = 0;
 
368
        int error = 0;
 
369
        int i;
 
370
        int pos;
 
371
 
 
372
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
373
        Stream_Seek(ifman->input, 16);
 
374
 
 
375
        Stream_Read_UINT32(ifman->input, numGeometryInfo);
 
376
        pos = Stream_GetPosition(ifman->input);
 
377
 
 
378
        Stream_Seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */
 
379
        Stream_Read_UINT32(ifman->input, Width);
 
380
        Stream_Read_UINT32(ifman->input, Height);
 
381
        Stream_Read_UINT32(ifman->input, Left);
 
382
        Stream_Read_UINT32(ifman->input, Top);
 
383
 
 
384
        Stream_SetPosition(ifman->input, pos + numGeometryInfo);
 
385
        Stream_Read_UINT32(ifman->input, cbVisibleRect);
 
386
        num_rects = cbVisibleRect / 16;
 
387
 
 
388
        DEBUG_DVC("numGeometryInfo %d Width %d Height %d Left %d Top %d cbVisibleRect %d num_rects %d",
 
389
                numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects);
 
390
 
 
391
        if (presentation == NULL)
 
392
        {
 
393
                error = 1;
 
394
        }
 
395
        else
 
396
        {
 
397
                if (num_rects > 0)
 
398
                {
 
399
                        rects = (RDP_RECT*) malloc(sizeof(RDP_RECT) * num_rects);
 
400
                        ZeroMemory(rects, sizeof(RDP_RECT) * num_rects);
 
401
 
 
402
                        for (i = 0; i < num_rects; i++)
 
403
                        {
 
404
                                Stream_Read_UINT16(ifman->input, rects[i].y); /* Top */
 
405
                                Stream_Seek_UINT16(ifman->input);
 
406
                                Stream_Read_UINT16(ifman->input, rects[i].x); /* Left */
 
407
                                Stream_Seek_UINT16(ifman->input);
 
408
                                Stream_Read_UINT16(ifman->input, rects[i].height); /* Bottom */
 
409
                                Stream_Seek_UINT16(ifman->input);
 
410
                                Stream_Read_UINT16(ifman->input, rects[i].width); /* Right */
 
411
                                Stream_Seek_UINT16(ifman->input);
 
412
                                rects[i].width -= rects[i].x;
 
413
                                rects[i].height -= rects[i].y;
 
414
 
 
415
                                DEBUG_DVC("rect %d: %d %d %d %d", i,
 
416
                                        rects[i].x, rects[i].y, rects[i].width, rects[i].height);
 
417
                        }
 
418
                }
 
419
                tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects, rects);
 
420
        }
 
421
        
 
422
        ifman->output_pending = TRUE;
 
423
 
 
424
        return error;
 
425
}
 
426
 
 
427
int tsmf_ifman_set_allocator(TSMF_IFMAN* ifman)
 
428
{
 
429
        DEBUG_DVC("");
 
430
        ifman->output_pending = TRUE;
 
431
        return 0;
 
432
}
 
433
 
 
434
int tsmf_ifman_notify_preroll(TSMF_IFMAN* ifman)
 
435
{
 
436
        DEBUG_DVC("");
 
437
        ifman->output_pending = TRUE;
 
438
        return 0;
 
439
}
 
440
 
 
441
int tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
 
442
{
 
443
        TSMF_PRESENTATION* presentation;
 
444
        TSMF_STREAM* stream;
 
445
        UINT32 StreamId;
 
446
        UINT64 SampleStartTime;
 
447
        UINT64 SampleEndTime;
 
448
        UINT64 ThrottleDuration;
 
449
        UINT32 SampleExtensions;
 
450
        UINT32 cbData;
 
451
 
 
452
        Stream_Seek(ifman->input, 16);
 
453
        Stream_Read_UINT32(ifman->input, StreamId);
 
454
        Stream_Seek_UINT32(ifman->input); /* numSample */
 
455
        Stream_Read_UINT64(ifman->input, SampleStartTime);
 
456
        Stream_Read_UINT64(ifman->input, SampleEndTime);
 
457
        Stream_Read_UINT64(ifman->input, ThrottleDuration);
 
458
        Stream_Seek_UINT32(ifman->input); /* SampleFlags */
 
459
        Stream_Read_UINT32(ifman->input, SampleExtensions);
 
460
        Stream_Read_UINT32(ifman->input, cbData);
 
461
        
 
462
        DEBUG_DVC("MessageId %d StreamId %d SampleStartTime %d SampleEndTime %d "
 
463
                "ThrottleDuration %d SampleExtensions %d cbData %d",
 
464
                ifman->message_id, StreamId, (int)SampleStartTime, (int)SampleEndTime,
 
465
                (int)ThrottleDuration, SampleExtensions, cbData);
 
466
 
 
467
        presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
 
468
 
 
469
        if (presentation == NULL)
 
470
        {
 
471
                DEBUG_WARN("unknown presentation id");
 
472
                return 1;
 
473
        }
 
474
 
 
475
        stream = tsmf_stream_find_by_id(presentation, StreamId);
 
476
 
 
477
        if (stream == NULL)
 
478
        {
 
479
                DEBUG_WARN("unknown stream id");
 
480
                return 1;
 
481
        }
 
482
 
 
483
        tsmf_stream_push_sample(stream, ifman->channel_callback,
 
484
                ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions,
 
485
                cbData, Stream_Pointer(ifman->input));
 
486
 
 
487
        ifman->output_pending = TRUE;
 
488
 
 
489
        return 0;
 
490
}
 
491
 
 
492
int tsmf_ifman_on_flush(TSMF_IFMAN* ifman)
 
493
{
 
494
        UINT32 StreamId;
 
495
        TSMF_PRESENTATION* presentation;
 
496
 
 
497
        Stream_Seek(ifman->input, 16);
 
498
        Stream_Read_UINT32(ifman->input, StreamId);
 
499
        DEBUG_DVC("StreamId %d", StreamId);
 
500
 
 
501
        presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
 
502
 
 
503
        if (presentation == NULL)
 
504
        {
 
505
                DEBUG_WARN("unknown presentation id");
 
506
                return 1;
 
507
        }
 
508
 
 
509
        tsmf_presentation_flush(presentation);
 
510
 
 
511
        ifman->output_pending = TRUE;
 
512
 
 
513
        return 0;
 
514
}
 
515
 
 
516
int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman)
 
517
{
 
518
        UINT32 StreamId;
 
519
        TSMF_STREAM* stream;
 
520
        TSMF_PRESENTATION* presentation;
 
521
 
 
522
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
523
        Stream_Seek(ifman->input, 16);
 
524
        Stream_Read_UINT32(ifman->input, StreamId);
 
525
 
 
526
        if (presentation)
 
527
        {
 
528
                stream = tsmf_stream_find_by_id(presentation, StreamId);
 
529
                if (stream)
 
530
                        tsmf_stream_end(stream);
 
531
        }
 
532
        DEBUG_DVC("StreamId %d", StreamId);
 
533
 
 
534
        Stream_EnsureRemainingCapacity(ifman->output, 16);
 
535
        Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
 
536
        Stream_Write_UINT32(ifman->output, StreamId); /* StreamId */
 
537
        Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */
 
538
        Stream_Write_UINT32(ifman->output, 0); /* cbData */
 
539
        ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
 
540
 
 
541
        return 0;
 
542
}
 
543
 
 
544
int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman)
 
545
{
 
546
        TSMF_PRESENTATION* presentation;
 
547
 
 
548
        DEBUG_DVC("");
 
549
 
 
550
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
551
 
 
552
        if (presentation)
 
553
                tsmf_presentation_start(presentation);
 
554
        else
 
555
                DEBUG_WARN("unknown presentation id");
 
556
 
 
557
        Stream_EnsureRemainingCapacity(ifman->output, 16);
 
558
        Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
 
559
        Stream_Write_UINT32(ifman->output, 0); /* StreamId */
 
560
        Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_START_COMPLETED); /* EventId */
 
561
        Stream_Write_UINT32(ifman->output, 0); /* cbData */
 
562
        ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
 
563
 
 
564
        return 0;
 
565
}
 
566
 
 
567
int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman)
 
568
{
 
569
        TSMF_PRESENTATION* presentation;
 
570
 
 
571
        DEBUG_DVC("");
 
572
        ifman->output_pending = TRUE;
 
573
 
 
574
        /* Added pause control so gstreamer pipeline can be paused accordingly */
 
575
 
 
576
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
577
 
 
578
        if (presentation)
 
579
                tsmf_presentation_paused(presentation);
 
580
        else
 
581
                DEBUG_WARN("unknown presentation id");
 
582
 
 
583
        return 0;
 
584
}
 
585
 
 
586
int tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman)
 
587
{
 
588
        TSMF_PRESENTATION* presentation;
 
589
 
 
590
        DEBUG_DVC("");
 
591
        ifman->output_pending = TRUE;
 
592
 
 
593
        /* Added restart control so gstreamer pipeline can be resumed accordingly */
 
594
 
 
595
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
596
 
 
597
        if (presentation)
 
598
                tsmf_presentation_restarted(presentation);
 
599
        else
 
600
                DEBUG_WARN("unknown presentation id");
 
601
        
 
602
        return 0;
 
603
}
 
604
 
 
605
int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman)
 
606
{
 
607
        TSMF_PRESENTATION* presentation;
 
608
 
 
609
        DEBUG_DVC("");
 
610
 
 
611
        presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input));
 
612
 
 
613
        if (presentation)
 
614
                tsmf_presentation_stop(presentation);
 
615
        else
 
616
                DEBUG_WARN("unknown presentation id");
 
617
 
 
618
        Stream_EnsureRemainingCapacity(ifman->output, 16);
 
619
        Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
 
620
        Stream_Write_UINT32(ifman->output, 0); /* StreamId */
 
621
        Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */
 
622
        Stream_Write_UINT32(ifman->output, 0); /* cbData */
 
623
        ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
 
624
 
 
625
        return 0;
 
626
}
 
627
 
 
628
int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman)
 
629
{
 
630
        DEBUG_DVC("");
 
631
 
 
632
        Stream_EnsureRemainingCapacity(ifman->output, 16);
 
633
        Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
 
634
        Stream_Write_UINT32(ifman->output, 0); /* StreamId */
 
635
        Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */
 
636
        Stream_Write_UINT32(ifman->output, 0); /* cbData */
 
637
        ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
 
638
 
 
639
        return 0;
 
640
}