00001
00034 #pragma once
00035
00036
00037 #include <map>
00038
00039
00040 #include "RtpDataQueue.h"
00041
00044 class RtpPacketManager
00045 {
00046 public:
00047
00048 RtpPacketManager(){;}
00049
00050 ~RtpPacketManager()
00051 {
00052
00053 for (std::map<int, RtpDataQueue*>::iterator it = m_dataQueues.begin(); it != m_dataQueues.end(); it++)
00054 {
00055 delete it->second;
00056 }
00057 }
00058
00059 void processMediaSample(int nSourceID, unsigned char* data, unsigned dataSize, double dStartTime, bool bHasBeenRtcpSynchronised)
00060 {
00061
00062 std::map<int, RtpDataQueue*>::iterator it = m_dataQueues.find(nSourceID);
00063 if (it != m_dataQueues.end())
00064 {
00065
00066 it->second->addMediaSample(data, dataSize, dStartTime, bHasBeenRtcpSynchronised);
00067 }
00068 }
00069
00070 bool createQueue(int nSourceID)
00071 {
00072
00073 std::map<int, RtpDataQueue*>::iterator it = m_dataQueues.find(nSourceID);
00074 if (it == m_dataQueues.end())
00075 {
00076 RtpDataQueue* pRtpQueue = new RtpDataQueue();
00077 m_dataQueues[nSourceID] = pRtpQueue;
00078 return true;
00079 }
00080 else
00081 {
00082 return false;
00083 }
00084 }
00085
00086 bool hasSamples(int nID)
00087 {
00088 if (!isBuffering())
00089 {
00090 std::map<int, RtpDataQueue*>::iterator it = m_dataQueues.find(nID);
00091 if (it != m_dataQueues.end())
00092 {
00093 return it->second->hasSamples();
00094 }
00095 }
00096 return false;
00097 }
00098
00099 MediaSample* getNextSample(int nID)
00100 {
00101 std::map<int, RtpDataQueue*>::iterator it = m_dataQueues.find(nID);
00102 if (it != m_dataQueues.end())
00103 {
00104 return it->second->getNextSample();
00105 }
00106 return NULL;
00107 }
00108
00109 bool isBuffering()
00110 {
00111 return false;
00112 }
00113
00114 private:
00115 std::map<int, RtpDataQueue*> m_dataQueues;
00116 };