xref: /haiku/src/add-ons/media/plugins/dvd_streamer/DVDStreamerPlugin.cpp (revision cb19342b8059634e6422e0cd5d1e16ab93455120)
11efb85deSBarrett17 /*
21efb85deSBarrett17  * Copyright 2019, Dario Casalinuovo. All rights reserved.
31efb85deSBarrett17  * Distributed under the terms of the MIT License.
41efb85deSBarrett17  */
51efb85deSBarrett17 
61efb85deSBarrett17 
7*cb19342bSBarrett17 #include "DVDStreamerPlugin.h"
81efb85deSBarrett17 
91efb85deSBarrett17 
101efb85deSBarrett17 B_DECLARE_CODEC_KIT_PLUGIN(
111efb85deSBarrett17 	DVDStreamerPlugin,
121efb85deSBarrett17 	"dvd_streamer",
131efb85deSBarrett17 	B_CODEC_KIT_PLUGIN_VERSION
141efb85deSBarrett17 );
151efb85deSBarrett17 
161efb85deSBarrett17 
171efb85deSBarrett17 DVDStreamer::DVDStreamer()
181efb85deSBarrett17 	:
19*cb19342bSBarrett17 	BStreamer(),
20*cb19342bSBarrett17 	fAdapter(NULL)
211efb85deSBarrett17 {
221efb85deSBarrett17 }
231efb85deSBarrett17 
241efb85deSBarrett17 
251efb85deSBarrett17 DVDStreamer::~DVDStreamer()
261efb85deSBarrett17 {
271efb85deSBarrett17 }
281efb85deSBarrett17 
291efb85deSBarrett17 
301efb85deSBarrett17 status_t
31*cb19342bSBarrett17 DVDStreamer::Sniff(const BUrl& url)
321efb85deSBarrett17 {
331efb85deSBarrett17 	BString path = url.UrlString();
341efb85deSBarrett17 	BString protocol = url.Protocol();
351efb85deSBarrett17 	if (protocol == "dvd") {
361efb85deSBarrett17 		path = path.RemoveFirst("dvd://");
371efb85deSBarrett17 	} else if (protocol == "file") {
381efb85deSBarrett17 		path = path.RemoveFirst("file://");
391efb85deSBarrett17 	} else
401efb85deSBarrett17 		return B_UNSUPPORTED;
411efb85deSBarrett17 
42*cb19342bSBarrett17 	DVDMediaIO* adapter = new DVDMediaIO(path);
43*cb19342bSBarrett17 	status_t ret = adapter->Open();
441efb85deSBarrett17 	if (ret == B_OK) {
45*cb19342bSBarrett17 		fAdapter = adapter;
461efb85deSBarrett17 		return B_OK;
471efb85deSBarrett17 	}
48*cb19342bSBarrett17 	delete adapter;
491efb85deSBarrett17 	return ret;
501efb85deSBarrett17 }
511efb85deSBarrett17 
521efb85deSBarrett17 
53*cb19342bSBarrett17 BMediaIO*
54*cb19342bSBarrett17 DVDStreamer::Adapter() const
55*cb19342bSBarrett17 {
56*cb19342bSBarrett17 	return fAdapter;
57*cb19342bSBarrett17 }
58*cb19342bSBarrett17 
59*cb19342bSBarrett17 
60*cb19342bSBarrett17 void
61*cb19342bSBarrett17 DVDStreamer::MouseMoved(uint32 x, uint32 y)
62*cb19342bSBarrett17 {
63*cb19342bSBarrett17 	fAdapter->MouseMoved(x, y);
64*cb19342bSBarrett17 }
65*cb19342bSBarrett17 
66*cb19342bSBarrett17 
67*cb19342bSBarrett17 void
68*cb19342bSBarrett17 DVDStreamer::MouseDown(uint32 x, uint32 y)
69*cb19342bSBarrett17 {
70*cb19342bSBarrett17 	fAdapter->MouseDown(x, y);
71*cb19342bSBarrett17 }
72*cb19342bSBarrett17 
73*cb19342bSBarrett17 
741efb85deSBarrett17 BStreamer*
751efb85deSBarrett17 DVDStreamerPlugin::NewStreamer()
761efb85deSBarrett17 {
771efb85deSBarrett17 	return new DVDStreamer();
781efb85deSBarrett17 }
79