-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base class for packet generating which will be used to create magazine, subtitle, packet 830 and databroadcast packet sources.
- Loading branch information
1 parent
ef6e41b
commit 2068d1f
Showing
5 changed files
with
177 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "packetsource.h" | ||
|
||
using namespace vbit; | ||
|
||
PacketSource::PacketSource() | ||
{ | ||
//ctor | ||
} | ||
|
||
PacketSource::~PacketSource() | ||
{ | ||
//dtor | ||
} | ||
|
||
|
||
Packet* PacketSource::GetPacket() | ||
{ | ||
Packet* pkt=new Packet(8,25," "); | ||
// Do your stuff | ||
return pkt; | ||
} | ||
|
||
bool PacketSource::IsReady() | ||
{ | ||
return false; // @todo This will probably just return a member bool | ||
} | ||
|
||
void PacketSource::SetEvent(Event event) | ||
{ | ||
//@todo Use event to clear the event flags which may have been set by the packet source being in wait. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** *************************************************************************** | ||
* Description : Interface for sources of packets: mag, subtitles etc. | ||
* Compiler : C++ | ||
* | ||
* Copyright (C) 2017, Peter Kwan | ||
* | ||
* Permission to use, copy, modify, and distribute this software | ||
* and its documentation for any purpose and without fee is hereby | ||
* granted, provided that the above copyright notice appear in all | ||
* copies and that both that the copyright notice and this | ||
* permission notice and warranty disclaimer appear in supporting | ||
* documentation, and that the name of the author not be used in | ||
* advertising or publicity pertaining to distribution of the | ||
* software without specific, written prior permission. | ||
* | ||
* The author disclaims all warranties with regard to this | ||
* software, including all implied warranties of merchantability | ||
* and fitness. In no event shall the author be liable for any | ||
* special, indirect or consequential damages or any damages | ||
* whatsoever resulting from loss of use, data or profits, whether | ||
* in an action of contract, negligence or other tortious action, | ||
* arising out of or in connection with the use or performance of | ||
* this software. | ||
*************************************************************************** | ||
**/ | ||
/** | ||
* Anything that generates teletext packets is derived from this interface. | ||
* Functions defined by this interface are | ||
* Constructor - sets up the data required by a particular packet source. | ||
* GetPacket - Gets the next packet in the stream. | ||
* Waiting - The stream is waiting for an event to restart it | ||
* SetEvent - Registers an even with the packet source | ||
* | ||
* Teletext packets come in four broad categories | ||
* 1) Magazines - Rows consisting of headers and body rows. | ||
* 2) Subtitles - Same as magazines but sent at highest priority. | ||
* 3) Packets on magazine 8, row 30 - Timing and control that happen on specific fields. | ||
* 4) Databroadcast - Packets that get sent at low priority and when possible. | ||
* | ||
* Events | ||
* 1) Field | ||
* 2) 10 fields | ||
* 3) Subtitle data in buffer | ||
* 4) All other streams are waiting (so we can now send databroadcast) | ||
**/ | ||
#ifndef _PACKETSOURCE_H_ | ||
#define _PACKETSOURCE_H_ | ||
|
||
#include "packet.h" | ||
|
||
namespace vbit{ | ||
|
||
/** @brief Events are used to trigger packet sources so that they may proceed | ||
* @description Different packet sources use different timing schemes. | ||
* Packet sources may put themselves into a waiting state. | ||
* Events are used to start them up again. | ||
* Magazines stop after a header and wait for the next field. | ||
* Subtitles wait until there is data in the subtitle buffer. | ||
* Packet 830 waits for a multiple of 10 fields. | ||
* Databroadcast varies according to the importance of the signal. | ||
* Lowest priority may only jump in only when a filler packet would be sent. | ||
* Highest priority might steal all the packets except for 830. | ||
*/ | ||
enum Event | ||
{ | ||
EVENT_FIELD, | ||
EVENT_P830_FORMAT_1, | ||
EVENT_P830_FORMAT_2_LABEL_0, | ||
EVENT_P830_FORMAT_2_LABEL_1, | ||
EVENT_P830_FORMAT_2_LABEL_2, | ||
EVENT_P830_FORMAT_2_LABEL_3, | ||
EVENT_SUBTITLE, | ||
EVENT_DATABROADCAST | ||
} ; | ||
|
||
|
||
class PacketSource | ||
{ | ||
public: | ||
/** Default constructor */ | ||
PacketSource(); | ||
/** Default destructor */ | ||
virtual ~PacketSource(); | ||
|
||
/** Get the next packet | ||
* @return The next packet OR if IsReady() would return false then a filler packet | ||
*/ | ||
virtual Packet* GetPacket()=0; | ||
|
||
/** Is there a packet ready to go? */ | ||
virtual bool IsReady(); // Don't need to Pure this. Just report a member bool | ||
|
||
/** Report that an event happened */ | ||
virtual void SetEvent(Event event); // Don't need to Pure this. All packet sources can use the same code | ||
|
||
protected: | ||
private: | ||
}; | ||
|
||
} // vbit namespace | ||
|
||
#endif // _PACKETSOURCE_H_ |