xref: /haiku/src/add-ons/media/plugins/dvd_streamer/DVDStreamerPlugin.cpp (revision 218a8c03cbadd95d8888b218930f514fa0b4fac4)
1 /*
2  * Copyright 2019, Dario Casalinuovo. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "DVDStreamerPlugin.h"
8 
9 
10 B_DECLARE_CODEC_KIT_PLUGIN(
11 	DVDStreamerPlugin,
12 	"dvd_streamer",
13 	B_CODEC_KIT_PLUGIN_VERSION
14 );
15 
16 
DVDStreamer()17 DVDStreamer::DVDStreamer()
18 	:
19 	BStreamer(),
20 	fAdapter(NULL)
21 {
22 }
23 
24 
~DVDStreamer()25 DVDStreamer::~DVDStreamer()
26 {
27 }
28 
29 
30 status_t
Sniff(const BUrl & url,BDataIO ** source)31 DVDStreamer::Sniff(const BUrl& url, BDataIO** source)
32 {
33 	BString path = url.UrlString();
34 	BString protocol = url.Protocol();
35 	if (protocol == "dvd") {
36 		path = path.RemoveFirst("dvd://");
37 	} else if (protocol == "file") {
38 		path = path.RemoveFirst("file://");
39 	} else
40 		return B_UNSUPPORTED;
41 
42 	DVDMediaIO* adapter = new DVDMediaIO(path);
43 	status_t ret = adapter->Open();
44 	if (ret == B_OK) {
45 		*source = adapter;
46 		return B_OK;
47 	}
48 	delete adapter;
49 	return ret;
50 }
51 
52 
53 #if 0
54 void
55 DVDStreamer::MouseMoved(uint32 x, uint32 y)
56 {
57 	fAdapter->MouseMoved(x, y);
58 }
59 
60 
61 void
62 DVDStreamer::MouseDown(uint32 x, uint32 y)
63 {
64 	fAdapter->MouseDown(x, y);
65 }
66 #endif
67 
68 
69 Streamer*
NewStreamer()70 DVDStreamerPlugin::NewStreamer()
71 {
72 	return new DVDStreamer();
73 }
74 
75 
76 MediaPlugin*
instantiate_plugin()77 instantiate_plugin()
78 {
79 	return new DVDStreamerPlugin();
80 }
81