1 /* 2 * Copyright 2017 Alistair Leslie-Hughes 3 * Copyright 2019 Vijay Kiran Kamuju 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 */ 19 #define COBJMACROS 20 #define WIN32_LEAN_AND_MEAN 21 #include "initguid.h" 22 #include "wmsdk.h" 23 24 #include "wine/test.h" 25 26 HRESULT WINAPI WMCreateWriterPriv(IWMWriter **writer); 27 28 static void test_wmwriter_interfaces(void) 29 { 30 HRESULT hr; 31 IWMWriter *writer; 32 IWMHeaderInfo *header; 33 IWMHeaderInfo2 *header2; 34 IWMHeaderInfo3 *header3; 35 36 hr = WMCreateWriter( NULL, &writer ); 37 ok(hr == S_OK, "WMCreateWriter failed 0x%08x\n", hr); 38 if(FAILED(hr)) 39 { 40 win_skip("Failed to create IWMWriter\n"); 41 return; 42 } 43 44 hr = IWMWriter_QueryInterface(writer, &IID_IWMHeaderInfo, (void **)&header); 45 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 46 47 hr = IWMWriter_QueryInterface(writer, &IID_IWMHeaderInfo2, (void **)&header2); 48 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 49 50 hr = IWMWriter_QueryInterface(writer, &IID_IWMHeaderInfo3, (void **)&header3); 51 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 52 53 if(header) 54 IWMHeaderInfo_Release(header); 55 if(header2) 56 IWMHeaderInfo2_Release(header2); 57 if(header3) 58 IWMHeaderInfo3_Release(header3); 59 IWMWriter_Release(writer); 60 } 61 62 static void test_wmreader_interfaces(void) 63 { 64 HRESULT hr; 65 IWMReader *reader; 66 IWMReaderAdvanced *advanced; 67 IWMReaderAdvanced2 *advanced2; 68 IWMHeaderInfo *header; 69 IWMHeaderInfo2 *header2; 70 IWMHeaderInfo3 *header3; 71 IWMProfile *profile; 72 IWMProfile2 *profile2; 73 IWMProfile3 *profile3; 74 IWMPacketSize *packet; 75 IWMPacketSize2 *packet2; 76 IWMReaderAccelerator *accel; 77 IWMReaderTimecode *timecode; 78 IWMReaderNetworkConfig *netconfig; 79 IWMReaderNetworkConfig2 *netconfig2; 80 IWMReaderStreamClock *clock; 81 IWMReaderTypeNegotiation *negotiation; 82 IWMDRMReader *drmreader; 83 IWMDRMReader2 *drmreader2; 84 IWMDRMReader3 *drmreader3; 85 IWMReaderPlaylistBurn *playlist; 86 IWMLanguageList *langlist; 87 IReferenceClock *refclock; 88 89 hr = WMCreateReader( NULL, 0, &reader ); 90 ok(hr == S_OK, "WMCreateReader failed 0x%08x\n", hr); 91 if(FAILED(hr)) 92 { 93 win_skip("Failed to create IWMReader\n"); 94 return; 95 } 96 97 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderAdvanced, (void **)&advanced); 98 ok(hr == S_OK, "Failed 0x%08x\n", hr); 99 100 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderAdvanced2, (void **)&advanced2); 101 ok(hr == S_OK, "Failed 0x%08x\n", hr); 102 103 hr = IWMReader_QueryInterface(reader, &IID_IWMHeaderInfo, (void **)&header); 104 ok(hr == S_OK, "Failed 0x%08x\n", hr); 105 106 hr = IWMReader_QueryInterface(reader, &IID_IWMHeaderInfo2, (void **)&header2); 107 ok(hr == S_OK, "Failed 0x%08x\n", hr); 108 109 hr = IWMReader_QueryInterface(reader, &IID_IWMHeaderInfo3, (void **)&header3); 110 ok(hr == S_OK, "Failed 0x%08x\n", hr); 111 112 hr = IWMReader_QueryInterface(reader, &IID_IWMProfile, (void **)&profile); 113 ok(hr == S_OK, "Failed 0x%08x\n", hr); 114 115 hr = IWMReader_QueryInterface(reader, &IID_IWMProfile2, (void **)&profile2); 116 ok(hr == S_OK, "Failed 0x%08x\n", hr); 117 118 hr = IWMReader_QueryInterface(reader, &IID_IWMProfile3, (void **)&profile3); 119 ok(hr == S_OK, "Failed 0x%08x\n", hr); 120 121 hr = IWMReader_QueryInterface(reader, &IID_IWMPacketSize, (void **)&packet); 122 ok(hr == S_OK, "Failed 0x%08x\n", hr); 123 124 hr = IWMReader_QueryInterface(reader, &IID_IWMPacketSize2, (void **)&packet2); 125 ok(hr == S_OK, "Failed 0x%08x\n", hr); 126 127 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderAccelerator, (void **)&accel); 128 ok(hr == S_OK, "Failed 0x%08x\n", hr); 129 130 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderTimecode, (void **)&timecode); 131 ok(hr == S_OK, "Failed 0x%08x\n", hr); 132 133 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderNetworkConfig, (void **)&netconfig); 134 ok(hr == S_OK, "Failed 0x%08x\n", hr); 135 136 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderNetworkConfig2, (void **)&netconfig2); 137 ok(hr == S_OK, "Failed 0x%08x\n", hr); 138 139 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderStreamClock, (void **)&clock); 140 ok(hr == S_OK, "Failed 0x%08x\n", hr); 141 142 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderTypeNegotiation, (void **)&negotiation); 143 ok(hr == S_OK, "Failed 0x%08x\n", hr); 144 145 hr = IWMReader_QueryInterface(reader, &IID_IWMDRMReader, (void **)&drmreader); 146 ok(hr == E_NOINTERFACE, "Failed 0x%08x\n", hr); 147 148 hr = IWMReader_QueryInterface(reader, &IID_IWMDRMReader2, (void **)&drmreader2); 149 ok(hr == E_NOINTERFACE, "Failed 0x%08x\n", hr); 150 151 hr = IWMReader_QueryInterface(reader, &IID_IWMDRMReader3, (void **)&drmreader3); 152 ok(hr == E_NOINTERFACE, "Failed 0x%08x\n", hr); 153 154 hr = IWMReader_QueryInterface(reader, &IID_IWMReaderPlaylistBurn, (void **)&playlist); 155 ok(hr == S_OK, "Failed 0x%08x\n", hr); 156 157 hr = IWMReader_QueryInterface(reader, &IID_IWMLanguageList, (void **)&langlist); 158 ok(hr == S_OK, "Failed 0x%08x\n", hr); 159 160 hr = IWMReader_QueryInterface(reader, &IID_IReferenceClock, (void **)&refclock); 161 ok(hr == S_OK, "Failed 0x%08x\n", hr); 162 163 if(packet) 164 IWMPacketSize_Release(packet); 165 if(packet2) 166 IWMPacketSize2_Release(packet2); 167 if(advanced) 168 IWMReaderAdvanced_Release(advanced); 169 if(advanced2) 170 IWMReaderAdvanced2_Release(advanced2); 171 if(profile) 172 IWMProfile_Release(profile); 173 if(profile2) 174 IWMProfile2_Release(profile2); 175 if(profile3) 176 IWMProfile3_Release(profile3); 177 if(header) 178 IWMHeaderInfo_Release(header); 179 if(header2) 180 IWMHeaderInfo2_Release(header2); 181 if(header3) 182 IWMHeaderInfo3_Release(header3); 183 if(accel) 184 IWMReaderAccelerator_Release(accel); 185 if(timecode) 186 IWMReaderTimecode_Release(timecode); 187 if(netconfig) 188 IWMReaderNetworkConfig_Release(netconfig); 189 if(netconfig2) 190 IWMReaderNetworkConfig2_Release(netconfig2); 191 if(clock) 192 IWMReaderStreamClock_Release(clock); 193 if(negotiation) 194 IWMReaderTypeNegotiation_Release(negotiation); 195 if(playlist) 196 IWMReaderPlaylistBurn_Release(playlist); 197 if(langlist) 198 IWMLanguageList_Release(langlist); 199 if(refclock) 200 IReferenceClock_Release(refclock); 201 202 IWMReader_Release(reader); 203 } 204 205 static void test_wmsyncreader_interfaces(void) 206 { 207 HRESULT hr; 208 IWMSyncReader *reader; 209 IWMHeaderInfo *header; 210 IWMHeaderInfo2 *header2; 211 IWMHeaderInfo3 *header3; 212 IWMProfile *profile; 213 IWMProfile2 *profile2; 214 IWMProfile3 *profile3; 215 IWMPacketSize *packet; 216 IWMPacketSize2 *packet2; 217 IWMReaderTimecode *timecode; 218 IWMReaderPlaylistBurn *playlist; 219 IWMLanguageList *langlist; 220 221 hr = WMCreateSyncReader( NULL, 0, &reader ); 222 ok(hr == S_OK, "WMCreateSyncReader failed 0x%08x\n", hr); 223 if(FAILED(hr)) 224 { 225 win_skip("Failed to create IWMSyncReader\n"); 226 return; 227 } 228 229 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMHeaderInfo, (void **)&header); 230 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 231 232 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMHeaderInfo2, (void **)&header2); 233 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 234 235 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMHeaderInfo3, (void **)&header3); 236 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 237 238 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMProfile, (void **)&profile); 239 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 240 241 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMProfile2, (void **)&profile2); 242 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 243 244 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMProfile3, (void **)&profile3); 245 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 246 247 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMPacketSize, (void **)&packet); 248 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 249 250 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMPacketSize2, (void **)&packet2); 251 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 252 253 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMReaderTimecode, (void **)&timecode); 254 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 255 256 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMReaderPlaylistBurn, (void **)&playlist); 257 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 258 259 hr = IWMSyncReader_QueryInterface(reader, &IID_IWMLanguageList, (void **)&langlist); 260 todo_wine ok(hr == S_OK, "Failed 0x%08x\n", hr); 261 262 if(packet) 263 IWMPacketSize_Release(packet); 264 if(packet2) 265 IWMPacketSize2_Release(packet2); 266 if(profile) 267 IWMProfile_Release(profile); 268 if(profile2) 269 IWMProfile2_Release(profile2); 270 if(profile3) 271 IWMProfile3_Release(profile3); 272 if(header) 273 IWMHeaderInfo_Release(header); 274 if(header2) 275 IWMHeaderInfo2_Release(header2); 276 if(header3) 277 IWMHeaderInfo3_Release(header3); 278 if(timecode) 279 IWMReaderTimecode_Release(timecode); 280 if(playlist) 281 IWMReaderPlaylistBurn_Release(playlist); 282 if(langlist) 283 IWMLanguageList_Release(langlist); 284 285 286 IWMSyncReader_Release(reader); 287 } 288 289 290 static void test_profile_manager_interfaces(void) 291 { 292 HRESULT hr; 293 IWMProfileManager *profile; 294 295 hr = WMCreateProfileManager(&profile); 296 ok(hr == S_OK, "WMCreateProfileManager failed 0x%08x\n", hr); 297 if(FAILED(hr)) 298 { 299 win_skip("Failed to create IWMProfileManager\n"); 300 return; 301 } 302 303 IWMProfileManager_Release(profile); 304 } 305 306 static void test_WMCreateWriterPriv(void) 307 { 308 IWMWriter *writer, *writer2; 309 HRESULT hr; 310 311 hr = WMCreateWriterPriv(&writer); 312 ok(hr == S_OK, "got 0x%08x\n", hr); 313 314 hr = IWMWriter_QueryInterface(writer, &IID_IWMWriter, (void**)&writer2); 315 ok(hr == S_OK, "got 0x%08x\n", hr); 316 317 IWMWriter_Release(writer); 318 IWMWriter_Release(writer2); 319 } 320 321 static void test_urlextension(void) 322 { 323 HRESULT hr; 324 const WCHAR mp3file[] = {'t','e','s','t','.','m','p','3',0}; 325 const WCHAR mkvfile[] = {'t','e','s','t','.','m','k','v',0}; 326 const WCHAR urlfile[] = {'a','b','c','d',':','/','/','t','e','s','t','/','t','e','s','t','.','w','m','v',0}; 327 const WCHAR testurl[] = {'h','t','t','p',':','/','/','t','e','s','t','/','t','.','a','s','f','?','a','l','t','=','t','.','m','k','v',0}; 328 329 hr = WMCheckURLExtension(NULL); 330 ok(hr == E_INVALIDARG, "WMCheckURLExtension failed 0x%08x\n", hr); 331 hr = WMCheckURLExtension(mkvfile); 332 ok(hr == NS_E_INVALID_NAME, "WMCheckURLExtension failed 0x%08x\n", hr); 333 hr = WMCheckURLExtension(mp3file); 334 todo_wine ok(hr == S_OK, "WMCheckURLExtension failed 0x%08x\n", hr); 335 hr = WMCheckURLExtension(urlfile); 336 todo_wine ok(hr == S_OK, "WMCheckURLExtension failed 0x%08x\n", hr); 337 hr = WMCheckURLExtension(testurl); 338 todo_wine ok(hr == S_OK, "WMCheckURLExtension failed 0x%08x\n", hr); 339 } 340 341 START_TEST(wmvcore) 342 { 343 HRESULT hr; 344 345 hr = CoInitialize(0); 346 ok(hr == S_OK, "failed to init com\n"); 347 if(hr != S_OK) 348 return; 349 350 test_wmreader_interfaces(); 351 test_wmsyncreader_interfaces(); 352 test_wmwriter_interfaces(); 353 test_profile_manager_interfaces(); 354 test_WMCreateWriterPriv(); 355 test_urlextension(); 356 357 CoUninitialize(); 358 } 359