1 /**
2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * FreeRDP Sample Server (Audio Input)
4 *
5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6 * Copyright 2015 Thincast Technologies GmbH
7 * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "sfreerdp.h"
27
28 #include "sf_audin.h"
29
30 #include <freerdp/server/server-common.h>
31 #include <freerdp/log.h>
32 #define TAG SERVER_TAG("sample")
33
34 /**
35 * Function description
36 *
37 * @return 0 on success, otherwise a Win32 error code
38 */
sf_peer_audin_opening(audin_server_context * context)39 static UINT sf_peer_audin_opening(audin_server_context* context)
40 {
41 WLog_DBG(TAG, "AUDIN opening.");
42 /* Simply choose the first format supported by the client. */
43 context->SelectFormat(context, 0);
44 return CHANNEL_RC_OK;
45 }
46
47 /**
48 * Function description
49 *
50 * @return 0 on success, otherwise a Win32 error code
51 */
sf_peer_audin_open_result(audin_server_context * context,UINT32 result)52 static UINT sf_peer_audin_open_result(audin_server_context* context, UINT32 result)
53 {
54 /* TODO: Implement */
55 WLog_WARN(TAG, "%s not implemented", __FUNCTION__);
56 WLog_DBG(TAG, "AUDIN open result %" PRIu32 ".", result);
57 return CHANNEL_RC_OK;
58 }
59
60 /**
61 * Function description
62 *
63 * @return 0 on success, otherwise a Win32 error code
64 */
sf_peer_audin_receive_samples(audin_server_context * context,const AUDIO_FORMAT * format,wStream * buf,size_t nframes)65 static UINT sf_peer_audin_receive_samples(audin_server_context* context, const AUDIO_FORMAT* format,
66 wStream* buf, size_t nframes)
67 {
68 /* TODO: Implement */
69 WLog_WARN(TAG, "%s not implemented", __FUNCTION__);
70 WLog_DBG(TAG, "%s receive %" PRIdz " frames.", __FUNCTION__, nframes);
71 return CHANNEL_RC_OK;
72 }
73
sf_peer_audin_init(testPeerContext * context)74 void sf_peer_audin_init(testPeerContext* context)
75 {
76 context->audin = audin_server_context_new(context->vcm);
77 context->audin->rdpcontext = &context->_p;
78 context->audin->data = context;
79 context->audin->num_server_formats = server_audin_get_formats(&context->audin->server_formats);
80
81 if (context->audin->num_server_formats > 0)
82 context->audin->dst_format = &context->audin->server_formats[0];
83
84 context->audin->Opening = sf_peer_audin_opening;
85 context->audin->OpenResult = sf_peer_audin_open_result;
86 context->audin->ReceiveSamples = sf_peer_audin_receive_samples;
87 }
88
sf_peer_audin_start(testPeerContext * context)89 BOOL sf_peer_audin_start(testPeerContext* context)
90 {
91 if (!context || !context->audin || !context->audin->Open)
92 return FALSE;
93
94 return context->audin->Open(context->audin);
95 }
96
sf_peer_audin_stop(testPeerContext * context)97 BOOL sf_peer_audin_stop(testPeerContext* context)
98 {
99 if (!context || !context->audin || !context->audin->Close)
100 return FALSE;
101
102 return context->audin->Close(context->audin);
103 }
104
sf_peer_audin_running(testPeerContext * context)105 BOOL sf_peer_audin_running(testPeerContext* context)
106 {
107 if (!context || !context->audin || !context->audin->IsOpen)
108 return FALSE;
109
110 return context->audin->IsOpen(context->audin);
111 }
112
sf_peer_audin_uninit(testPeerContext * context)113 void sf_peer_audin_uninit(testPeerContext* context)
114 {
115 if (context)
116 audin_server_context_free(context->audin);
117 }
118