summaryrefslogtreecommitdiffstats
path: root/xrdpapi/vrplayer.c
blob: 442ef35efef5d46e74d98adea81e5cf47511063a (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
/**
 * xrdp: A Remote Desktop Protocol server.
 *
 * Copyright (C) Laxmikant Rashinkar 2012 LK.Rashinkar@gmail.com
 *
 * 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.
 *
 * a program that uses xrdpapi and ffmpeg to redirect media streams
 * to a FreeRDP client where it is decompressed and played locally
 *
 */

/******************************************************************************
 * build instructions:  make -f vrplayer.mk
 * setup environment:   export LD_LIBRARY_PATH=".libs:../xrdpvr/.libs"
 * run vrplayer:        vrplayer <media file>
 *****************************************************************************/

#ifdef __WIN32__
#include <mstsapi.h>
#endif

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>

#include "xrdpapi.h"
#include "xrdpvr.h"

void
extract_32(uint32_t *value, char *buf)
{
    *value =  ((buf[3] << 24) & 0xff000000)
              | ((buf[2] << 16) & 0x00ff0000)
              | ((buf[1] <<  8) & 0x0000ff00)
              |  (buf[0]        & 0x000000ff);
}

int
main(int argc, char **argv)
{
    char    *data;
    char    *data1;
    void    *channel;
    int     written = 0;
    int     rv;
    int     first_time = 1;
    int     length;
    int     bytes_read;

    if (argc < 2)
    {
        printf("usage: vrplayer <media filename> >\n");
        return 1;
    }

    /* open a virtual channel and connect to remote client */
    channel = WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, "xrdpvr", 0);

    if (channel == NULL)
    {
        fprintf(stderr, "WTSVirtualChannelOpenEx() failed\n");
        return 1;
    }

    /* initialize the player */
    if (xrdpvr_init_player(channel, 101, argv[1]))
    {
        fprintf(stderr, "failed to initialize the player\n");
        return 1;
    }

    /* send compressed media data to client; client will decompress */
    /* the media and play it locally                                */
    xrdpvr_play_media(channel, 101, argv[1]);

    /* perform clean up */
    xrdpvr_deinit_player(channel, 101);

    WTSVirtualChannelClose(channel);
    return 0;
}