1/*
2 * PlaylistFileReader.h - Media Player for the Haiku Operating System
3 *
4 * Copyright (C) 2006 Marcus Overhagen 	<marcus@overhagen.de>
5 * Copyright (C) 2007-2009 Stephan A��mus <superstippi@gmx.de> (MIT ok)
6 * Copyright (C) 2008-2009 Fredrik Mod��en <[FirstName]@[LastName].se> (MIT ok)
7 *
8 * Released under the terms of the MIT license.
9 */
10#ifndef __PLAYLIST_FILE_READER_H
11#define __PLAYLIST_FILE_READER_H
12
13
14#include <SupportDefs.h>
15
16class BString;
17struct entry_ref;
18class Playlist;
19
20enum PlaylistFileType {m3u, pls, unknown};
21
22
23class PlaylistFileReader {
24public:
25	virtual						~PlaylistFileReader() {}
26		// Defined to enable deletion of PlaylistFileReader* target objects.
27
28	virtual	void				AppendToPlaylist(const entry_ref& ref,
29									Playlist* playlist) = 0;
30	static	PlaylistFileReader*	GenerateReader(const entry_ref& ref);
31		// Returns a pointer to an object of the appropriate derived class,
32		// or returns NULL if the argument is not a valid playlist file.
33
34protected:
35			int32				_AppendItemToPlaylist(const BString& entry, Playlist* playlist);
36		// Returns the track's playlist index if it was successfully added, else returns -1.
37		// BString& entry is a (absolute or relative) file path or URL
38
39private:
40	static	PlaylistFileType	_IdentifyType(const entry_ref& ref);
41};
42
43
44class M3uReader : public PlaylistFileReader {
45public:
46	virtual	void				AppendToPlaylist(const entry_ref& ref, Playlist* playlist);
47};
48
49
50class PlsReader : public PlaylistFileReader {
51public:
52	virtual void				AppendToPlaylist(const entry_ref& ref,
53									Playlist* playlist);
54private:
55			status_t			_ParseTitleLine(const BString& title, Playlist* playlist,
56									const int32 lastAssignedIndex);
57			status_t			_ParseLengthLine(const BString& length, Playlist* playlist,
58									const int32 lastAssignedIndex);
59};
60
61
62#endif
63