/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; UINT32 newVolume; UINT32 muted; DEBUG_TSMF("on stream volume"); if (Stream_GetRemainingLength(ifman->input) < GUID_SIZE + 8) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (!presentation) { WLog_ERR(TAG, "unknown presentation id"); return ERROR_NOT_FOUND; } Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, newVolume); DEBUG_TSMF("on stream volume: new volume=[%d]", newVolume); Stream_Read_UINT32(ifman->input, muted); DEBUG_TSMF("on stream volume: muted=[%d]", muted); if (!tsmf_presentation_volume_changed(presentation, newVolume, muted)) return ERROR_INVALID_OPERATION; ifman->output_pending = TRUE; return 0; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); if (Stream_GetRemainingLength(ifman->input) < GUID_SIZE) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_free(presentation); else { WLog_ERR(TAG, "unknown presentation id"); return ERROR_NOT_FOUND; } if (!Stream_EnsureRemainingCapacity(ifman->output, 4)) return ERROR_OUTOFMEMORY; Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return CHANNEL_RC_OK; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman) { UINT status = CHANNEL_RC_OK; float Left, Top; float Right, Bottom; TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); if (Stream_GetRemainingLength(ifman->input) < 32) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, GUID_SIZE); if (!presentation) { status = ERROR_NOT_FOUND; } else { Left = tsmf_stream_read_float(ifman->input); /* Left (4 bytes) */ Top = tsmf_stream_read_float(ifman->input); /* Top (4 bytes) */ Right = tsmf_stream_read_float(ifman->input); /* Right (4 bytes) */ Bottom = tsmf_stream_read_float(ifman->input); /* Bottom (4 bytes) */ DEBUG_TSMF("SetSourceVideoRect: Left: %f Top: %f Right: %f Bottom: %f", Left, Top, Right, Bottom); } ifman->output_pending = TRUE; return status; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) { int status = CHANNEL_RC_OK; UINT32 StreamId; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); if (Stream_GetRemainingLength(ifman->input) < 20) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, GUID_SIZE); if (!presentation) { status = ERROR_NOT_FOUND; } else { Stream_Read_UINT32(ifman->input, StreamId); stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream) tsmf_stream_free(stream); else status = ERROR_NOT_FOUND; } ifman->output_pending = TRUE; return status; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_channel_volume(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_TSMF("on channel volume"); if (Stream_GetRemainingLength(ifman->input) < GUID_SIZE + 8) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { UINT32 channelVolume; UINT32 changedChannel; Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, channelVolume); DEBUG_TSMF("on channel volume: channel volume=[%d]", channelVolume); Stream_Read_UINT32(ifman->input, changedChannel); DEBUG_TSMF("on stream volume: changed channel=[%d]", changedChannel); } ifman->output_pending = TRUE; return CHANNEL_RC_OK; }
TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCallback* pChannelCallback) { TSMF_PRESENTATION* presentation; pthread_t thid = pthread_self(); FILE* fout = NULL; fout = fopen("/tmp/tsmf.tid", "wt"); if (fout) { fprintf(fout, "%d\n", (int) (size_t) thid); fclose(fout); } presentation = tsmf_presentation_find_by_id(guid); if (presentation) { DEBUG_WARN("duplicated presentation id!"); return NULL; } presentation = (TSMF_PRESENTATION*) malloc(sizeof(TSMF_PRESENTATION)); ZeroMemory(presentation, sizeof(TSMF_PRESENTATION)); memcpy(presentation->presentation_id, guid, GUID_SIZE); presentation->channel_callback = pChannelCallback; presentation->mutex = CreateMutex(NULL, FALSE, NULL); presentation->stream_list = list_new(); list_enqueue(presentation_list, presentation); return presentation; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman) { UINT status = CHANNEL_RC_OK; TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); if (Stream_GetRemainingLength(ifman->input) < GUID_SIZE) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { DEBUG_TSMF("Presentation already exists"); ifman->output_pending = FALSE; return CHANNEL_RC_OK; } presentation = tsmf_presentation_new(Stream_Pointer(ifman->input), ifman->channel_callback); if (!presentation) status = ERROR_OUTOFMEMORY; else tsmf_presentation_set_audio_device(presentation, ifman->audio_name, ifman->audio_device); ifman->output_pending = TRUE; return status; }
int tsmf_ifman_on_stream_volume(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_DVC("on stream volume"); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { UINT32 newVolume; UINT32 muted; Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, newVolume); DEBUG_DVC("on stream volume: new volume=[%d]", newVolume); Stream_Read_UINT32(ifman->input, muted); DEBUG_DVC("on stream volume: muted=[%d]", muted); tsmf_presentation_volume_changed(presentation, newVolume, muted); } else { DEBUG_WARN("unknown presentation id"); } ifman->output_pending = TRUE; return 0; }
int tsmf_ifman_set_source_video_rect(TSMF_IFMAN* ifman) { int status = 0; float Left, Top; float Right, Bottom; TSMF_PRESENTATION* presentation; DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); if (!presentation) { status = 1; } else { Left = tsmf_stream_read_float(ifman->input); /* Left (4 bytes) */ Top = tsmf_stream_read_float(ifman->input); /* Top (4 bytes) */ Right = tsmf_stream_read_float(ifman->input); /* Right (4 bytes) */ Bottom = tsmf_stream_read_float(ifman->input); /* Bottom (4 bytes) */ DEBUG_DVC("SetSourceVideoRect: Left: %f Top: %f Right: %f Bottom: %f", Left, Top, Right, Bottom); } ifman->output_pending = TRUE; return status; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) { UINT32 StreamId; TSMF_STREAM* stream = NULL; TSMF_PRESENTATION* presentation; if (Stream_GetRemainingLength(ifman->input) < 20) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, StreamId); if (presentation) { stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream) tsmf_stream_end(stream, ifman->message_id, ifman->channel_callback); } DEBUG_TSMF("StreamId %d", StreamId); ifman->output_pending = TRUE; ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return CHANNEL_RC_OK; }
int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) { int status = 0; UINT32 StreamId; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); if (presentation == NULL) { status = 1; } else { Stream_Read_UINT32(ifman->input, StreamId); stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream) tsmf_stream_free(stream); else status = 1; } ifman->output_pending = TRUE; return status; }
int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) { UINT32 StreamId; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, StreamId); if (presentation) { stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream) tsmf_stream_end(stream); } DEBUG_DVC("StreamId %d", StreamId); Stream_EnsureRemainingCapacity(ifman->output, 16); 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 */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman) { int status = 0; TSMF_PRESENTATION* presentation; DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { DEBUG_DVC("Presentation already exists"); ifman->output_pending = FALSE; return 0; } presentation = tsmf_presentation_new(Stream_Pointer(ifman->input), ifman->channel_callback); if (presentation == NULL) status = 1; else tsmf_presentation_set_audio_device(presentation, ifman->audio_name, ifman->audio_device); ifman->output_pending = TRUE; return status; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { if (!tsmf_presentation_stop(presentation)) return ERROR_INVALID_OPERATION; } else WLog_ERR(TAG, "unknown presentation id"); if (!Stream_EnsureRemainingCapacity(ifman->output, 16)) return ERROR_OUTOFMEMORY; 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 */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return CHANNEL_RC_OK; }
int tsmf_ifman_add_stream(TSMF_IFMAN* ifman) { UINT32 StreamId; int status = 0; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, 16); if (presentation == NULL) { status = 1; } else { Stream_Read_UINT32(ifman->input, StreamId); Stream_Seek_UINT32(ifman->input); /* numMediaType */ stream = tsmf_stream_new(presentation, StreamId); if (stream) tsmf_stream_set_format(stream, ifman->decoder_name, ifman->input); } ifman->output_pending = TRUE; return status; }
int tsmf_ifman_update_geometry_info(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; uint32 numGeometryInfo; uint32 Left; uint32 Top; uint32 Width; uint32 Height; uint32 cbVisibleRect; RD_RECT * rects = NULL; int num_rects = 0; int i; int error = 0; numGeometryInfo = GET_UINT32(ifman->input_buffer, 16); Width = GET_UINT32(ifman->input_buffer, 20 + 12); Height = GET_UINT32(ifman->input_buffer, 20 + 16); Left = GET_UINT32(ifman->input_buffer, 20 + 20); Top = GET_UINT32(ifman->input_buffer, 20 + 24); cbVisibleRect = GET_UINT32(ifman->input_buffer, 20 + numGeometryInfo); num_rects = cbVisibleRect / 16; LLOGLN(10, ("tsmf_ifman_update_geometry_info: numGeometryInfo %d " "Width %d Height %d Left %d Top %d cbVisibleRect %d num_rects %d", numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects)); presentation = tsmf_presentation_find_by_id(ifman->input_buffer); if (presentation == NULL) error = 1; else { if (num_rects > 0) { rects = (RD_RECT *) malloc(sizeof(RD_RECT) * num_rects); for (i = 0; i < num_rects; i++) { rects[i].x = (uint16) GET_UINT32(ifman->input_buffer, 24 + numGeometryInfo + i * 16 + 4); rects[i].y = (uint16) GET_UINT32(ifman->input_buffer, 24 + numGeometryInfo + i * 16); rects[i].width = (uint16) GET_UINT32(ifman->input_buffer, 24 + numGeometryInfo + i * 16 + 12) - rects[i].x; rects[i].height = (uint16) GET_UINT32(ifman->input_buffer, 24 + numGeometryInfo + i * 16 + 8) - rects[i].y; LLOGLN(10, ("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); } ifman->output_pending = 1; return 0; }
int tsmf_ifman_on_sample(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; TSMF_STREAM* stream; UINT32 StreamId; UINT64 SampleStartTime; UINT64 SampleEndTime; UINT64 ThrottleDuration; UINT32 SampleExtensions; UINT32 cbData; Stream_Seek(ifman->input, 16); 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); 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); if (presentation == NULL) { DEBUG_WARN("unknown presentation id"); return 1; } stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream == NULL) { DEBUG_WARN("unknown stream id"); return 1; } tsmf_stream_push_sample(stream, ifman->channel_callback, ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions, cbData, Stream_Pointer(ifman->input)); ifman->output_pending = TRUE; return 0; }
int tsmf_ifman_shutdown_presentation(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; LLOGLN(0, ("tsmf_ifman_shutdown_presentation:")); presentation = tsmf_presentation_find_by_id(ifman->input_buffer); if (presentation) tsmf_presentation_free(presentation); ifman->output_buffer_size = 4; ifman->output_buffer = malloc(4); SET_UINT32(ifman->output_buffer, 0, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
int tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_DVC(""); ifman->output_pending = TRUE; /* Added restart control so gstreamer pipeline can be resumed accordingly */ presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_restarted(presentation); else DEBUG_WARN("unknown presentation id"); return 0; }
int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_free(presentation); else DEBUG_WARN("unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 4); Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
int tsmf_ifman_on_sample(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; TSMF_STREAM * stream; uint32 StreamId; uint64 SampleStartTime; uint64 SampleEndTime; uint64 ThrottleDuration; uint32 SampleExtensions; uint32 cbData; StreamId = GET_UINT32(ifman->input_buffer, 16); SampleStartTime = GET_UINT64(ifman->input_buffer, 24); SampleEndTime = GET_UINT64(ifman->input_buffer, 32); ThrottleDuration = GET_UINT64(ifman->input_buffer, 40); SampleExtensions = GET_UINT32(ifman->input_buffer, 52); cbData = GET_UINT32(ifman->input_buffer, 56); LLOGLN(10, ("tsmf_ifman_on_sample: 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); if (presentation == NULL) { LLOGLN(0, ("tsmf_ifman_on_sample: unknown presentation id")); return 1; } stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream == NULL) { LLOGLN(0, ("tsmf_ifman_on_sample: unknown stream id")); return 1; } tsmf_stream_push_sample(stream, ifman->channel_callback, ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions, cbData, ifman->input_buffer + 60); ifman->output_pending = 1; return 0; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_playback_restarted(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); ifman->output_pending = TRUE; /* Added restart control so gstreamer pipeline can be resumed accordingly */ presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) { if (!tsmf_presentation_restarted(presentation)) return ERROR_INVALID_OPERATION; } else WLog_ERR(TAG, "unknown presentation id"); return CHANNEL_RC_OK; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_add_stream(TSMF_IFMAN* ifman, rdpContext* rdpcontext) { UINT32 StreamId; UINT status = CHANNEL_RC_OK; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; DEBUG_TSMF(""); if (Stream_GetRemainingLength(ifman->input) < GUID_SIZE + 8) return ERROR_INVALID_DATA; presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); Stream_Seek(ifman->input, GUID_SIZE); if (!presentation) { WLog_ERR(TAG, "unknown presentation id"); status = ERROR_NOT_FOUND; } else { Stream_Read_UINT32(ifman->input, StreamId); Stream_Seek_UINT32(ifman->input); /* numMediaType */ stream = tsmf_stream_new(presentation, StreamId, rdpcontext); if (!stream) { WLog_ERR(TAG, "failed to create stream"); return ERROR_OUTOFMEMORY; } if (!tsmf_stream_set_format(stream, ifman->decoder_name, ifman->input)) { WLog_ERR(TAG, "failed to set stream format"); return ERROR_OUTOFMEMORY; } } ifman->output_pending = TRUE; return status; }
int tsmf_ifman_on_flush(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; uint32 StreamId; StreamId = GET_UINT32(ifman->input_buffer, 16); LLOGLN(0, ("tsmf_ifman_on_flush: StreamId %d", StreamId)); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); if (presentation == NULL) { LLOGLN(0, ("tsmf_ifman_on_sample: unknown presentation id")); return 1; } tsmf_presentation_flush(presentation); ifman->output_pending = 1; return 0; }
static int tsmf_on_close(IWTSVirtualChannelCallback* pChannelCallback) { TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*) pChannelCallback; DEBUG_DVC(""); if (callback->stream_id) { presentation = tsmf_presentation_find_by_id(callback->presentation_id); if (presentation) { stream = tsmf_stream_find_by_id(presentation, callback->stream_id); if (stream) tsmf_stream_free(stream); } } xfree(pChannelCallback); return 0; }
int tsmf_ifman_on_playback_stopped(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(Stream_Pointer(ifman->input)); if (presentation) tsmf_presentation_stop(presentation); else DEBUG_WARN("unknown presentation id"); Stream_EnsureRemainingCapacity(ifman->output, 16); 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 */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
int tsmf_ifman_add_stream(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; TSMF_STREAM * stream; uint32 StreamId; int error = 0; LLOGLN(0, ("tsmf_ifman_add_stream:")); presentation = tsmf_presentation_find_by_id(ifman->input_buffer); if (presentation == NULL) error = 1; else { StreamId = GET_UINT32(ifman->input_buffer, 16); stream = tsmf_stream_new(presentation, StreamId); if (stream) tsmf_stream_set_format(stream, ifman->decoder_name, ifman->input_buffer + 24); } ifman->output_pending = 1; return error; }
int tsmf_ifman_on_playback_stopped(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; LLOGLN(0, ("tsmf_ifman_on_playback_stopped:")); presentation = tsmf_presentation_find_by_id(ifman->input_buffer); if (presentation) tsmf_presentation_stop(presentation); else LLOGLN(0, ("tsmf_ifman_on_playback_stopped: unknown presentation id")); ifman->output_buffer_size = 16; ifman->output_buffer = malloc(16); SET_UINT32(ifman->output_buffer, 0, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ SET_UINT32(ifman->output_buffer, 4, 0); /* StreamId */ SET_UINT32(ifman->output_buffer, 8, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */ SET_UINT32(ifman->output_buffer, 12, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
int tsmf_ifman_on_flush(TSMF_IFMAN* ifman) { UINT32 StreamId; TSMF_PRESENTATION* presentation; Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, StreamId); DEBUG_DVC("StreamId %d", StreamId); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); if (presentation == NULL) { DEBUG_WARN("unknown presentation id"); return 1; } tsmf_presentation_flush(presentation); ifman->output_pending = TRUE; return 0; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_ifman_on_flush(TSMF_IFMAN* ifman) { UINT32 StreamId; TSMF_PRESENTATION* presentation; TSMF_STREAM* stream; if (Stream_GetRemainingLength(ifman->input) < 20) return ERROR_INVALID_DATA; Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, StreamId); DEBUG_TSMF("StreamId %d", StreamId); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); if (!presentation) { WLog_ERR(TAG, "unknown presentation id"); return ERROR_NOT_FOUND; } /* Flush message is for a stream, not the entire presentation * therefore we only flush the stream as intended per the MS-RDPEV spec */ stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream) { if (!tsmf_stream_flush(stream)) return ERROR_INVALID_OPERATION; } else WLog_ERR(TAG, "unknown stream id"); ifman->output_pending = TRUE; return CHANNEL_RC_OK; }