xref: /haiku/src/add-ons/media/plugins/dvd_streamer/DVDStreamerPlugin.cpp (revision 1efb85decc7f5c50838a53f35d000c8377f5ecc1)
1*1efb85deSBarrett17 /*
2*1efb85deSBarrett17  * Copyright 2019, Dario Casalinuovo. All rights reserved.
3*1efb85deSBarrett17  * Distributed under the terms of the MIT License.
4*1efb85deSBarrett17  */
5*1efb85deSBarrett17 
6*1efb85deSBarrett17 #include "DVDStreamerPlugin.h"
7*1efb85deSBarrett17 
8*1efb85deSBarrett17 #include "DVDMediaIO.h"
9*1efb85deSBarrett17 
10*1efb85deSBarrett17 
11*1efb85deSBarrett17 B_DECLARE_CODEC_KIT_PLUGIN(
12*1efb85deSBarrett17 	DVDStreamerPlugin,
13*1efb85deSBarrett17 	"dvd_streamer",
14*1efb85deSBarrett17 	B_CODEC_KIT_PLUGIN_VERSION
15*1efb85deSBarrett17 );
16*1efb85deSBarrett17 
17*1efb85deSBarrett17 
18*1efb85deSBarrett17 DVDStreamer::DVDStreamer()
19*1efb85deSBarrett17 	:
20*1efb85deSBarrett17 	BStreamer()
21*1efb85deSBarrett17 {
22*1efb85deSBarrett17 }
23*1efb85deSBarrett17 
24*1efb85deSBarrett17 
25*1efb85deSBarrett17 DVDStreamer::~DVDStreamer()
26*1efb85deSBarrett17 {
27*1efb85deSBarrett17 }
28*1efb85deSBarrett17 
29*1efb85deSBarrett17 
30*1efb85deSBarrett17 status_t
31*1efb85deSBarrett17 DVDStreamer::Sniff(const BUrl& url, BDataIO** source)
32*1efb85deSBarrett17 {
33*1efb85deSBarrett17 	BString path = url.UrlString();
34*1efb85deSBarrett17 	BString protocol = url.Protocol();
35*1efb85deSBarrett17 	if (protocol == "dvd") {
36*1efb85deSBarrett17 		path = path.RemoveFirst("dvd://");
37*1efb85deSBarrett17 	} else if(protocol == "file") {
38*1efb85deSBarrett17 		path = path.RemoveFirst("file://");
39*1efb85deSBarrett17 	} else
40*1efb85deSBarrett17 		return B_UNSUPPORTED;
41*1efb85deSBarrett17 
42*1efb85deSBarrett17 	DVDMediaIO* outSource = new DVDMediaIO(path);
43*1efb85deSBarrett17 	status_t ret = outSource->Open();
44*1efb85deSBarrett17 	if (ret == B_OK) {
45*1efb85deSBarrett17 		*source = outSource;
46*1efb85deSBarrett17 		return B_OK;
47*1efb85deSBarrett17 	}
48*1efb85deSBarrett17 	delete outSource;
49*1efb85deSBarrett17 	return ret;
50*1efb85deSBarrett17 }
51*1efb85deSBarrett17 
52*1efb85deSBarrett17 
53*1efb85deSBarrett17 BStreamer*
54*1efb85deSBarrett17 DVDStreamerPlugin::NewStreamer()
55*1efb85deSBarrett17 {
56*1efb85deSBarrett17 	return new DVDStreamer();
57*1efb85deSBarrett17 }
58