1 /* 2 * Copyright 2017, Dario Casalinuovo 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6 7 #include "MediaStreamer.h" 8 9 #include <stdio.h> 10 #include <string.h> 11 12 #include "MediaDebug.h" 13 14 #include "PluginManager.h" 15 16 17 MediaStreamer::MediaStreamer(BUrl url) 18 : 19 fStreamer(NULL) 20 { 21 CALLED(); 22 23 fUrl = url; 24 } 25 26 27 MediaStreamer::~MediaStreamer() 28 { 29 CALLED(); 30 31 if (fStreamer != NULL) 32 gPluginManager.DestroyStreamer(fStreamer); 33 } 34 35 36 status_t 37 MediaStreamer::CreateAdapter(BDataIO** adapter) 38 { 39 CALLED(); 40 41 // NOTE: Consider splitting the streamer creation and 42 // sniff in PluginManager. 43 if (fStreamer != NULL) 44 gPluginManager.DestroyStreamer(fStreamer); 45 46 return gPluginManager.CreateStreamer(&fStreamer, fUrl, adapter); 47 } 48