| 1 |
/* |
| 2 |
* Copyright (C) 2010-2021 Team Kodi (https://kodi.tv) |
| 3 |
* Copyright (C) 2010 Alwin Esch (Team Kodi) |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSE.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include <kodi/addon-instance/PVR.h> |
| 12 |
#include <stddef.h> |
| 13 |
#include <stdint.h> |
| 14 |
#include <stdio.h> |
| 15 |
|
| 16 |
class ATTR_DLL_LOCAL cResponsePacket |
| 17 |
{ |
| 18 |
public: |
| 19 |
cResponsePacket(kodi::addon::CInstancePVRClient& instance); |
| 20 |
~cResponsePacket(); |
| 21 |
|
| 22 |
void setResponse(uint8_t* packet, size_t packetLength); |
| 23 |
void setStatus(uint8_t* packet, size_t packetLength); |
| 24 |
void setStream(uint8_t* packet, size_t packetLength); |
| 25 |
void setOSD(uint8_t* packet, size_t packetLength); |
| 26 |
|
| 27 |
void extractHeader(); |
| 28 |
void extractStreamHeader(); |
| 29 |
void extractOSDHeader(); |
| 30 |
|
| 31 |
bool noResponse() { return (m_userData == NULL); }; |
| 32 |
|
| 33 |
size_t getUserDataLength() const { return m_userDataLength; } |
| 34 |
uint32_t getChannelID() const { return m_channelID; } |
| 35 |
uint32_t getRequestID() const { return m_requestID; } |
| 36 |
uint32_t getStreamID() const { return m_streamID; } |
| 37 |
uint32_t getOpCodeID() const { return m_opcodeID; } |
| 38 |
uint32_t getDuration() const { return m_duration; } |
| 39 |
int64_t getDTS() const { return m_dts; } |
| 40 |
int64_t getPTS() const { return m_pts; } |
| 41 |
uint32_t getMuxSerial() const { return m_muxSerial; } |
| 42 |
void getOSDData( |
| 43 |
uint32_t& wnd, uint32_t& color, uint32_t& x0, uint32_t& y0, uint32_t& x1, uint32_t& y1); |
| 44 |
|
| 45 |
size_t getPacketPos() const { return m_packetPos; } |
| 46 |
size_t getRemainingLength() const { return m_userDataLength - m_packetPos; } |
| 47 |
|
| 48 |
char* extract_String(); |
| 49 |
uint8_t extract_U8(); |
| 50 |
uint32_t extract_U32(); |
| 51 |
uint64_t extract_U64(); |
| 52 |
int32_t extract_S32(); |
| 53 |
int64_t extract_S64(); |
| 54 |
double extract_Double(); |
| 55 |
|
| 56 |
// If you call this, the memory becomes yours. Free with free() |
| 57 |
uint8_t* stealUserData(); |
| 58 |
|
| 59 |
uint8_t* getUserData(); |
| 60 |
|
| 61 |
uint8_t* getHeader() { return m_header; }; |
| 62 |
size_t getStreamHeaderLength() const { return 36; }; |
| 63 |
size_t getHeaderLength() const { return 8; }; |
| 64 |
size_t getOSDHeaderLength() const { return 32; }; |
| 65 |
|
| 66 |
private: |
| 67 |
uint8_t m_header[40]; |
| 68 |
uint8_t* m_userData = nullptr; |
| 69 |
size_t m_userDataLength = 0; |
| 70 |
size_t m_packetPos = 0; |
| 71 |
|
| 72 |
uint32_t m_channelID = 0; |
| 73 |
|
| 74 |
uint32_t m_requestID = 0; |
| 75 |
uint32_t m_streamID = 0; |
| 76 |
uint32_t m_opcodeID; |
| 77 |
uint32_t m_duration; |
| 78 |
int64_t m_dts; |
| 79 |
int64_t m_pts; |
| 80 |
uint32_t m_muxSerial; |
| 81 |
|
| 82 |
int32_t m_osdWnd; |
| 83 |
int32_t m_osdColor; |
| 84 |
|
| 85 |
int32_t m_osdX0; |
| 86 |
int32_t m_osdY0; |
| 87 |
int32_t m_osdX1; |
| 88 |
int32_t m_osdY1; |
| 89 |
|
| 90 |
kodi::addon::CInstancePVRClient& m_instance; |
| 91 |
}; |