2011-09-19 18:54:09 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-09-19 18:54:09 +04:00
|
|
|
* Video Redirection Virtual Channel - Interface Manipulation
|
|
|
|
*
|
|
|
|
* Copyright 2010-2011 Vic Lee
|
2012-06-13 23:45:58 +04:00
|
|
|
* Copyright 2012 Hewlett-Packard Development Company, L.P.
|
2011-09-19 18:54:09 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-11-20 08:49:08 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
#include <freerdp/utils/stream.h>
|
|
|
|
|
2012-09-23 03:25:21 +04:00
|
|
|
#include "tsmf_types.h"
|
2011-09-19 18:54:09 +04:00
|
|
|
#include "tsmf_constants.h"
|
|
|
|
#include "tsmf_media.h"
|
|
|
|
#include "tsmf_codec.h"
|
|
|
|
|
|
|
|
#include "tsmf_ifman.h"
|
|
|
|
|
|
|
|
int tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 CapabilityValue;
|
2011-09-19 18:54:09 +04:00
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, CapabilityValue);
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("server CapabilityValue %d", CapabilityValue);
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 8);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, 1); /* CapabilityValue */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* Result */
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 i;
|
|
|
|
UINT32 v;
|
|
|
|
UINT32 pos;
|
|
|
|
UINT32 CapabilityType;
|
|
|
|
UINT32 cbCapabilityLength;
|
|
|
|
UINT32 numHostCapabilities;
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
pos = stream_get_pos(ifman->output);
|
|
|
|
stream_check_size(ifman->output, ifman->input_size + 4);
|
|
|
|
stream_copy(ifman->output, ifman->input, ifman->input_size);
|
|
|
|
|
|
|
|
stream_set_pos(ifman->output, pos);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->output, numHostCapabilities);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
for (i = 0; i < numHostCapabilities; i++)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->output, CapabilityType);
|
|
|
|
stream_read_UINT32(ifman->output, cbCapabilityLength);
|
2011-09-19 18:54:09 +04:00
|
|
|
pos = stream_get_pos(ifman->output);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
switch (CapabilityType)
|
|
|
|
{
|
|
|
|
case 1: /* Protocol version request */
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->output, v);
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("server protocol version %d", v);
|
|
|
|
break;
|
|
|
|
case 2: /* Supported platform */
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_peek_UINT32(ifman->output, v);
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("server supported platform %d", v);
|
|
|
|
/* Claim that we support both MF and DShow platforms. */
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output,
|
2011-09-19 18:54:09 +04:00
|
|
|
MMREDIR_CAPABILITY_PLATFORM_MF | MMREDIR_CAPABILITY_PLATFORM_DSHOW);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUG_WARN("unknown capability type %d", CapabilityType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
stream_set_pos(ifman->output, pos + cbCapabilityLength);
|
|
|
|
}
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, 0); /* Result */
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_check_format_support_request(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 numMediaType;
|
|
|
|
UINT32 PlatformCookie;
|
|
|
|
UINT32 FormatSupported = 1;
|
2011-09-19 18:54:09 +04:00
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, PlatformCookie);
|
|
|
|
stream_seek_UINT32(ifman->input); /* NoRolloverFlags (4 bytes) */
|
|
|
|
stream_read_UINT32(ifman->input, numMediaType);
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
DEBUG_DVC("PlatformCookie %d numMediaType %d", PlatformCookie, numMediaType);
|
|
|
|
|
|
|
|
if (!tsmf_codec_check_media_type(ifman->input))
|
|
|
|
FormatSupported = 0;
|
|
|
|
|
|
|
|
if (FormatSupported)
|
|
|
|
DEBUG_DVC("format ok.");
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 12);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, FormatSupported);
|
|
|
|
stream_write_UINT32(ifman->output, PlatformCookie);
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* Result */
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
static TSMF_PRESENTATION* pexisted = 0;
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-11-20 08:49:08 +04:00
|
|
|
int status = 0;
|
2011-09-19 18:54:09 +04:00
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
|
|
|
DEBUG_DVC("");
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
if (pexisted)
|
|
|
|
{
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = FALSE;
|
2012-06-13 23:45:58 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
presentation = tsmf_presentation_new(stream_get_tail(ifman->input), ifman->channel_callback);
|
2012-06-13 23:45:58 +04:00
|
|
|
pexisted = presentation;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (presentation == NULL)
|
2012-11-20 08:49:08 +04:00
|
|
|
status = 1;
|
2012-05-16 17:29:35 +04:00
|
|
|
else
|
|
|
|
tsmf_presentation_set_audio_device(presentation, ifman->audio_name, ifman->audio_device);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
|
|
|
return status;
|
2011-09-19 18:54:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_add_stream(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 StreamId;
|
2012-11-20 08:49:08 +04:00
|
|
|
int status = 0;
|
2011-09-19 18:54:09 +04:00
|
|
|
TSMF_STREAM* stream;
|
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
|
|
|
stream_seek(ifman->input, 16);
|
|
|
|
|
|
|
|
if (presentation == NULL)
|
2012-11-20 08:49:08 +04:00
|
|
|
{
|
|
|
|
status = 1;
|
|
|
|
}
|
2011-09-19 18:54:09 +04:00
|
|
|
else
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, StreamId);
|
|
|
|
stream_seek_UINT32(ifman->input); /* numMediaType */
|
2011-09-19 18:54:09 +04:00
|
|
|
stream = tsmf_stream_new(presentation, StreamId);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (stream)
|
|
|
|
tsmf_stream_set_format(stream, ifman->decoder_name, ifman->input);
|
|
|
|
}
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
|
|
|
return status;
|
2011-09-19 18:54:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 8);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, 1); /* TopologyReady */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* Result */
|
2011-09-19 18:54:09 +04:00
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-11-20 08:49:08 +04:00
|
|
|
int status = 0;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 StreamId;
|
2011-09-19 18:54:09 +04:00
|
|
|
TSMF_STREAM* stream;
|
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
|
|
|
stream_seek(ifman->input, 16);
|
|
|
|
|
|
|
|
if (presentation == NULL)
|
2012-11-20 08:49:08 +04:00
|
|
|
{
|
|
|
|
status = 1;
|
|
|
|
}
|
2011-09-19 18:54:09 +04:00
|
|
|
else
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, StreamId);
|
2011-09-19 18:54:09 +04:00
|
|
|
stream = tsmf_stream_find_by_id(presentation, StreamId);
|
|
|
|
if (stream)
|
|
|
|
tsmf_stream_free(stream);
|
|
|
|
else
|
2012-11-20 08:49:08 +04:00
|
|
|
status = 1;
|
2011-09-19 18:54:09 +04:00
|
|
|
}
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
|
|
|
return status;
|
2011-09-19 18:54:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (presentation)
|
|
|
|
tsmf_presentation_free(presentation);
|
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
pexisted = 0;
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
stream_check_size(ifman->output, 4);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, 0); /* Result */
|
2011-09-19 18:54:09 +04:00
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-06-13 23:45:58 +04:00
|
|
|
TSMF_PRESENTATION* presentation;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
|
|
|
DEBUG_DVC("on stream volume");
|
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
if (presentation)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 newVolume;
|
|
|
|
UINT32 muted;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
|
|
|
stream_seek(ifman->input, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, newVolume);
|
2012-06-13 23:45:58 +04:00
|
|
|
DEBUG_DVC("on stream volume: new volume=[%d]", newVolume);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, muted);
|
2012-06-13 23:45:58 +04:00
|
|
|
DEBUG_DVC("on stream volume: muted=[%d]", muted);
|
|
|
|
tsmf_presentation_volume_changed(presentation, newVolume, muted);
|
|
|
|
}
|
|
|
|
else
|
2012-07-29 06:24:14 +04:00
|
|
|
{
|
2012-06-13 23:45:58 +04:00
|
|
|
DEBUG_WARN("unknown presentation id");
|
2012-07-29 06:24:14 +04:00
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-06-13 23:45:58 +04:00
|
|
|
TSMF_PRESENTATION* presentation;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
|
|
|
DEBUG_DVC("on channel volume");
|
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
if (presentation)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 channelVolume;
|
|
|
|
UINT32 changedChannel;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
|
|
|
stream_seek(ifman->input, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, channelVolume);
|
2012-06-13 23:45:58 +04:00
|
|
|
DEBUG_DVC("on channel volume: channel volume=[%d]", channelVolume);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, changedChannel);
|
2012-06-13 23:45:58 +04:00
|
|
|
DEBUG_DVC("on stream volume: changed channel=[%d]", changedChannel);
|
|
|
|
}
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_set_video_window(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
DEBUG_DVC("");
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
TSMF_PRESENTATION* presentation;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 numGeometryInfo;
|
|
|
|
UINT32 Left;
|
|
|
|
UINT32 Top;
|
|
|
|
UINT32 Width;
|
|
|
|
UINT32 Height;
|
|
|
|
UINT32 cbVisibleRect;
|
2011-09-19 18:54:09 +04:00
|
|
|
RDP_RECT* rects = NULL;
|
|
|
|
int num_rects = 0;
|
|
|
|
int error = 0;
|
|
|
|
int i;
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
|
|
|
stream_seek(ifman->input, 16);
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, numGeometryInfo);
|
2011-09-19 18:54:09 +04:00
|
|
|
pos = stream_get_pos(ifman->input);
|
|
|
|
|
|
|
|
stream_seek(ifman->input, 12); /* VideoWindowId (8 bytes), VideoWindowState (4 bytes) */
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, Width);
|
|
|
|
stream_read_UINT32(ifman->input, Height);
|
|
|
|
stream_read_UINT32(ifman->input, Left);
|
|
|
|
stream_read_UINT32(ifman->input, Top);
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
stream_set_pos(ifman->input, pos + numGeometryInfo);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, cbVisibleRect);
|
2011-09-19 18:54:09 +04:00
|
|
|
num_rects = cbVisibleRect / 16;
|
|
|
|
|
|
|
|
DEBUG_DVC("numGeometryInfo %d Width %d Height %d Left %d Top %d cbVisibleRect %d num_rects %d",
|
|
|
|
numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects);
|
|
|
|
|
|
|
|
if (presentation == NULL)
|
2012-07-29 06:24:14 +04:00
|
|
|
{
|
2011-09-19 18:54:09 +04:00
|
|
|
error = 1;
|
2012-07-29 06:24:14 +04:00
|
|
|
}
|
2011-09-19 18:54:09 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (num_rects > 0)
|
|
|
|
{
|
2012-11-20 08:49:08 +04:00
|
|
|
rects = (RDP_RECT*) malloc(sizeof(RDP_RECT) * num_rects);
|
|
|
|
ZeroMemory(rects, sizeof(RDP_RECT) * num_rects);
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
for (i = 0; i < num_rects; i++)
|
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
stream_read_UINT16(ifman->input, rects[i].y); /* Top */
|
|
|
|
stream_seek_UINT16(ifman->input);
|
|
|
|
stream_read_UINT16(ifman->input, rects[i].x); /* Left */
|
|
|
|
stream_seek_UINT16(ifman->input);
|
|
|
|
stream_read_UINT16(ifman->input, rects[i].height); /* Bottom */
|
|
|
|
stream_seek_UINT16(ifman->input);
|
|
|
|
stream_read_UINT16(ifman->input, rects[i].width); /* Right */
|
|
|
|
stream_seek_UINT16(ifman->input);
|
2011-09-19 18:54:09 +04:00
|
|
|
rects[i].width -= rects[i].x;
|
|
|
|
rects[i].height -= rects[i].y;
|
|
|
|
|
|
|
|
DEBUG_DVC("rect %d: %d %d %d %d", i,
|
|
|
|
rects[i].x, rects[i].y, rects[i].width, rects[i].height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects, rects);
|
|
|
|
}
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_set_allocator(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
DEBUG_DVC("");
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_notify_preroll(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
DEBUG_DVC("");
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_sample(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
TSMF_STREAM* stream;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 StreamId;
|
|
|
|
UINT64 SampleStartTime;
|
|
|
|
UINT64 SampleEndTime;
|
|
|
|
UINT64 ThrottleDuration;
|
|
|
|
UINT32 SampleExtensions;
|
|
|
|
UINT32 cbData;
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
stream_seek(ifman->input, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, StreamId);
|
|
|
|
stream_seek_UINT32(ifman->input); /* numSample */
|
|
|
|
stream_read_UINT64(ifman->input, SampleStartTime);
|
|
|
|
stream_read_UINT64(ifman->input, SampleEndTime);
|
|
|
|
stream_read_UINT64(ifman->input, ThrottleDuration);
|
|
|
|
stream_seek_UINT32(ifman->input); /* SampleFlags */
|
|
|
|
stream_read_UINT32(ifman->input, SampleExtensions);
|
|
|
|
stream_read_UINT32(ifman->input, cbData);
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
DEBUG_DVC("MessageId %d StreamId %d SampleStartTime %d SampleEndTime %d "
|
|
|
|
"ThrottleDuration %d SampleExtensions %d cbData %d",
|
|
|
|
ifman->message_id, StreamId, (int)SampleStartTime, (int)SampleEndTime,
|
|
|
|
(int)ThrottleDuration, SampleExtensions, cbData);
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (presentation == NULL)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("unknown presentation id");
|
|
|
|
return 1;
|
|
|
|
}
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
stream = tsmf_stream_find_by_id(presentation, StreamId);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (stream == NULL)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("unknown stream id");
|
|
|
|
return 1;
|
|
|
|
}
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
tsmf_stream_push_sample(stream, ifman->channel_callback,
|
|
|
|
ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions,
|
|
|
|
cbData, stream_get_tail(ifman->input));
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_flush(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 StreamId;
|
2012-11-20 08:49:08 +04:00
|
|
|
TSMF_PRESENTATION* presentation;
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
stream_seek(ifman->input, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, StreamId);
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("StreamId %d", StreamId);
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(ifman->presentation_id);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (presentation == NULL)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("unknown presentation id");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
tsmf_presentation_flush(presentation);
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 StreamId;
|
2012-11-20 08:49:08 +04:00
|
|
|
TSMF_STREAM* stream;
|
|
|
|
TSMF_PRESENTATION* presentation;
|
2011-09-19 18:54:09 +04:00
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
|
|
|
stream_seek(ifman->input, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_read_UINT32(ifman->input, StreamId);
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2012-05-16 17:29:35 +04:00
|
|
|
if (presentation)
|
|
|
|
{
|
|
|
|
stream = tsmf_stream_find_by_id(presentation, StreamId);
|
|
|
|
if (stream)
|
|
|
|
tsmf_stream_end(stream);
|
|
|
|
}
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("StreamId %d", StreamId);
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
|
|
|
|
stream_write_UINT32(ifman->output, StreamId); /* StreamId */
|
|
|
|
stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* cbData */
|
2011-09-19 18:54:09 +04:00
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (presentation)
|
|
|
|
tsmf_presentation_start(presentation);
|
|
|
|
else
|
|
|
|
DEBUG_WARN("unknown presentation id");
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* StreamId */
|
|
|
|
stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_START_COMPLETED); /* EventId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* cbData */
|
2011-09-19 18:54:09 +04:00
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-07-29 06:24:14 +04:00
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("");
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-06-13 23:45:58 +04:00
|
|
|
|
|
|
|
/* Added pause control so gstreamer pipeline can be paused accordingly */
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
if (presentation)
|
|
|
|
tsmf_presentation_paused(presentation);
|
|
|
|
else
|
|
|
|
DEBUG_WARN("unknown presentation id");
|
2012-11-20 08:49:08 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman)
|
|
|
|
{
|
2012-07-29 06:24:14 +04:00
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
DEBUG_DVC("");
|
2012-10-09 10:31:28 +04:00
|
|
|
ifman->output_pending = TRUE;
|
2012-06-13 23:45:58 +04:00
|
|
|
|
|
|
|
/* Added restart control so gstreamer pipeline can be resumed accordingly */
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
if (presentation)
|
|
|
|
tsmf_presentation_restarted(presentation);
|
|
|
|
else
|
|
|
|
DEBUG_WARN("unknown presentation id");
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman)
|
|
|
|
{
|
|
|
|
TSMF_PRESENTATION* presentation;
|
|
|
|
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input));
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2011-09-19 18:54:09 +04:00
|
|
|
if (presentation)
|
|
|
|
tsmf_presentation_stop(presentation);
|
|
|
|
else
|
|
|
|
DEBUG_WARN("unknown presentation id");
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* StreamId */
|
|
|
|
stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* cbData */
|
2011-09-19 18:54:09 +04:00
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman)
|
|
|
|
{
|
|
|
|
DEBUG_DVC("");
|
|
|
|
|
|
|
|
stream_check_size(ifman->output, 16);
|
2012-10-09 11:26:39 +04:00
|
|
|
stream_write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* StreamId */
|
|
|
|
stream_write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */
|
|
|
|
stream_write_UINT32(ifman->output, 0); /* cbData */
|
2011-09-19 18:54:09 +04:00
|
|
|
ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|