20 #include <freerdp/config.h>
22 #include <winpr/assert.h>
26 #include <freerdp/codecs.h>
28 #define TAG FREERDP_TAG("core.codecs")
30 static void codecs_free_int(rdpCodecs* codecs, UINT32 flags)
34 if (flags & FREERDP_CODEC_REMOTEFX)
38 rfx_context_free(codecs->rfx);
43 if (flags & FREERDP_CODEC_NSCODEC)
47 nsc_context_free(codecs->nsc);
53 if (flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444))
57 h264_context_free(codecs->h264);
63 if (flags & FREERDP_CODEC_CLEARCODEC)
67 clear_context_free(codecs->clear);
72 if (flags & FREERDP_CODEC_PROGRESSIVE)
74 if (codecs->progressive)
76 progressive_context_free(codecs->progressive);
77 codecs->progressive = NULL;
81 if (flags & FREERDP_CODEC_PLANAR)
85 freerdp_bitmap_planar_context_free(codecs->planar);
86 codecs->planar = NULL;
90 if (flags & FREERDP_CODEC_INTERLEAVED)
92 if (codecs->interleaved)
94 bitmap_interleaved_context_free(codecs->interleaved);
95 codecs->interleaved = NULL;
99 BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags, UINT32 width, UINT32 height)
101 codecs_free_int(codecs, flags);
102 if ((flags & FREERDP_CODEC_INTERLEAVED))
104 if (!(codecs->interleaved = bitmap_interleaved_context_new(FALSE)))
106 WLog_ERR(TAG,
"Failed to create interleaved codec context");
111 if ((flags & FREERDP_CODEC_PLANAR))
113 if (!(codecs->planar = freerdp_bitmap_planar_context_new(0, 64, 64)))
115 WLog_ERR(TAG,
"Failed to create planar bitmap codec context");
120 if ((flags & FREERDP_CODEC_NSCODEC))
122 if (!(codecs->nsc = nsc_context_new()))
124 WLog_ERR(TAG,
"Failed to create nsc codec context");
129 if ((flags & FREERDP_CODEC_REMOTEFX))
131 if (!(codecs->rfx = rfx_context_new_ex(FALSE, codecs->ThreadingFlags)))
133 WLog_ERR(TAG,
"Failed to create rfx codec context");
138 if ((flags & FREERDP_CODEC_CLEARCODEC))
140 if (!(codecs->clear = clear_context_new(FALSE)))
142 WLog_ERR(TAG,
"Failed to create clear codec context");
147 if (flags & FREERDP_CODEC_ALPHACODEC)
151 if ((flags & FREERDP_CODEC_PROGRESSIVE))
153 if (!(codecs->progressive = progressive_context_new_ex(FALSE, codecs->ThreadingFlags)))
155 WLog_ERR(TAG,
"Failed to create progressive codec context");
161 if ((flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444)))
163 if (!(codecs->h264 = h264_context_new(FALSE)))
165 WLog_WARN(TAG,
"Failed to create h264 codec context");
170 return freerdp_client_codecs_reset(codecs, flags, width, height);
173 BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags, UINT32 width, UINT32 height)
177 if (flags & FREERDP_CODEC_INTERLEAVED)
179 if (codecs->interleaved)
181 rc &= bitmap_interleaved_context_reset(codecs->interleaved);
185 if (flags & FREERDP_CODEC_PLANAR)
189 rc &= freerdp_bitmap_planar_context_reset(codecs->planar, width, height);
193 if (flags & FREERDP_CODEC_NSCODEC)
197 rc &= nsc_context_reset(codecs->nsc, width, height);
201 if (flags & FREERDP_CODEC_REMOTEFX)
205 rc &= rfx_context_reset(codecs->rfx, width, height);
209 if (flags & FREERDP_CODEC_CLEARCODEC)
213 rc &= clear_context_reset(codecs->clear);
217 if (flags & FREERDP_CODEC_ALPHACODEC)
221 if (flags & FREERDP_CODEC_PROGRESSIVE)
223 if (codecs->progressive)
225 rc &= progressive_context_reset(codecs->progressive);
230 if (flags & (FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444))
234 rc &= h264_context_reset(codecs->h264, width, height);
242 rdpCodecs* codecs_new(rdpContext* context)
244 if (!context || !context->settings)
248 return freerdp_client_codecs_new(flags);
251 void codecs_free(rdpCodecs* codecs)
253 freerdp_client_codecs_free(codecs);
256 rdpCodecs* freerdp_client_codecs_new(UINT32 ThreadingFlags)
258 rdpCodecs* codecs = (rdpCodecs*)calloc(1,
sizeof(rdpCodecs));
263 codecs->ThreadingFlags = ThreadingFlags;
268 void freerdp_client_codecs_free(rdpCodecs* codecs)
273 codecs_free_int(codecs, FREERDP_CODEC_ALL);
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.