00001 #ifndef BASIC_SOURCE_H 00002 #define BASIC_SOURCE_H 00003 00004 00005 #include <vector> 00006 #include <string> 00007 #include "audiere.h" 00008 00009 00010 namespace audiere { 00011 00012 struct Tag { 00013 Tag(const std::string& k, const std::string& v, const std::string& t) { 00014 key = k; 00015 value = v; 00016 type = t; 00017 } 00018 00019 std::string key; 00020 std::string value; 00021 std::string type; 00022 }; 00023 00029 class BasicSource : public RefImplementation<SampleSource> { 00030 public: 00031 BasicSource(); 00032 00037 int ADR_CALL read(int frame_count, void* buffer); 00038 00039 bool ADR_CALL isSeekable() { return false; } 00040 int ADR_CALL getLength() { return 0; } 00041 void ADR_CALL setPosition(int /*position*/) { } 00042 int ADR_CALL getPosition() { return 0; } 00043 00044 bool ADR_CALL getRepeat() { return m_repeat; } 00045 void ADR_CALL setRepeat(bool repeat) { m_repeat = repeat; } 00046 00047 int ADR_CALL getTagCount() { return int(m_tags.size()); } 00048 const char* ADR_CALL getTagKey(int i) { return m_tags[i].key.c_str(); } 00049 const char* ADR_CALL getTagValue(int i) { return m_tags[i].value.c_str(); } 00050 const char* ADR_CALL getTagType(int i) { return m_tags[i].type.c_str(); } 00051 00053 virtual int doRead(int frame_count, void* buffer) = 0; 00054 00055 protected: 00056 void addTag(const Tag& t) { 00057 m_tags.push_back(t); 00058 } 00059 00060 void addTag(const std::string& k, const std::string& v, const std::string& t) { 00061 addTag(Tag(k, v, t)); 00062 } 00063 00064 private: 00065 bool m_repeat; 00066 std::vector<Tag> m_tags; 00067 }; 00068 00069 } 00070 00071 00072 #endif