SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Public Attributes | Private Attributes | List of all members
leansdr::s2_framer Struct Reference

#include <dvbs2.h>

+ Inheritance diagram for leansdr::s2_framer:
+ Collaboration diagram for leansdr::s2_framer:

Public Member Functions

 s2_framer (scheduler *sch, pipebuf< tspacket > &_in, pipebuf< bbframe > &_out)
 
void run ()
 
- Public Member Functions inherited from leansdr::runnable
 runnable (scheduler *_sch, const char *name)
 
- Public Member Functions inherited from leansdr::runnable_common
 runnable_common (const char *_name)
 
virtual ~runnable_common ()
 
virtual void shutdown ()
 

Public Attributes

uint8_t rolloff_code
 
s2_pls pls
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Private Attributes

pipereader< tspacketin
 
pipewriter< bbframeout
 
crc8_engine crc8
 
int nremain
 
uint8_t rembuf [tspacket::SIZE]
 
uint8_t remcrc
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

Definition at line 2430 of file dvbs2.h.

Constructor & Destructor Documentation

◆ s2_framer()

leansdr::s2_framer::s2_framer ( scheduler sch,
pipebuf< tspacket > &  _in,
pipebuf< bbframe > &  _out 
)
inline

Definition at line 2434 of file dvbs2.h.

References leansdr::s2_pls::modcod, leansdr::s2_pls::pilots, and leansdr::s2_pls::sf.

2435  : runnable(sch, "S2 framer"),
2436  in(_in), out(_out)
2437  {
2438  pls.modcod = 4;
2439  pls.sf = false;
2440  pls.pilots = true;
2441  nremain = 0;
2442  remcrc = 0; // CRC for nonexistent previous packet
2443  }
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
bool pilots
Definition: dvbs2.h:202
pipewriter< bbframe > out
Definition: dvbs2.h:2504
uint8_t remcrc
Definition: dvbs2.h:2508
pipereader< tspacket > in
Definition: dvbs2.h:2503
scheduler * sch
Definition: framework.h:199

Member Function Documentation

◆ run()

void leansdr::s2_framer::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 2444 of file dvbs2.h.

References leansdr::bbframe::bytes, leansdr::check_modcod(), leansdr::tspacket::data, leansdr::fail(), leansdr::s2_pls::modcod, leansdr::bbframe::pls, leansdr::modcod_info::rate, leansdr::pipereader< T >::rd(), leansdr::pipereader< T >::read(), leansdr::pipereader< T >::readable(), leansdr::s2_pls::sf, leansdr::tspacket::SIZE, leansdr::pipewriter< T >::wr(), leansdr::pipewriter< T >::writable(), and leansdr::pipewriter< T >::written().

2445  {
2446  while (out.writable() >= 1)
2447  {
2448  const modcod_info *mcinfo = check_modcod(pls.modcod);
2449  const fec_info *fi = &fec_infos[pls.sf][mcinfo->rate];
2450  int framebytes = fi->Kbch / 8;
2451  if (!framebytes)
2452  fail("MODCOD/framesize combination not allowed");
2453  if (10 + nremain + 188 * in.readable() < framebytes)
2454  break; // Not enough data to fill a frame
2455  bbframe *pout = out.wr();
2456  pout->pls = pls;
2457  uint8_t *buf = pout->bytes;
2458  uint8_t *end = buf + framebytes;
2459  // EN 302 307-1 section 5.1.6 Base-Band Header insertion
2460  uint8_t *bbheader = buf;
2461  *buf++ = 0x30 | rolloff_code; // MATYPE-1: SIS, CCM
2462  *buf++ = 0; // MATYPE-2
2463  uint16_t upl = 188 * 8;
2464  *buf++ = upl >> 8; // UPL MSB
2465  *buf++ = upl; // UPL LSB
2466  uint16_t dfl = (framebytes - 10) * 8;
2467  *buf++ = dfl >> 8; // DFL MSB
2468  *buf++ = dfl; // DFL LSB
2469  *buf++ = 0x47; // SYNC
2470  uint16_t syncd = nremain * 8;
2471  *buf++ = syncd >> 8; // SYNCD MSB
2472  *buf++ = syncd; // SYNCD LSB
2473  *buf++ = crc8.compute(bbheader, 9);
2474  // Data field
2475  memcpy(buf, rembuf, nremain); // Leftover from previous runs
2476  buf += nremain;
2477  while (buf < end)
2478  {
2479  tspacket *tsp = in.rd();
2480  if (tsp->data[0] != MPEG_SYNC)
2481  fail("Invalid TS");
2482  *buf++ = remcrc; // Replace SYNC with CRC of previous.
2483  remcrc = crc8.compute(tsp->data + 1, tspacket::SIZE - 1);
2484  int nused = end - buf;
2485  if (nused > tspacket::SIZE - 1)
2486  nused = tspacket::SIZE - 1;
2487  memcpy(buf, tsp->data + 1, nused);
2488  buf += nused;
2489  if (buf == end)
2490  {
2491  nremain = (tspacket::SIZE - 1) - nused;
2492  memcpy(rembuf, tsp->data + 1 + nused, nremain);
2493  }
2494  in.read(1);
2495  }
2496  if (buf != end)
2497  fail("Bug: s2_framer");
2498  out.written(1);
2499  }
2500  }
uint8_t rolloff_code
Definition: dvbs2.h:2432
unsigned char uint8_t
Definition: rtptypes_win.h:42
static const int SIZE
Definition: dvb.h:1173
unsigned short uint16_t
Definition: rtptypes_win.h:44
void fail(const char *s)
Definition: framework.cpp:11
uint8_t rembuf[tspacket::SIZE]
Definition: dvbs2.h:2507
pipewriter< bbframe > out
Definition: dvbs2.h:2504
uint8_t remcrc
Definition: dvbs2.h:2508
pipereader< tspacket > in
Definition: dvbs2.h:2503
const modcod_info * check_modcod(int m)
Definition: dvbs2.h:285
crc8_engine crc8
Definition: dvbs2.h:2505
uint8_t compute(const uint8_t *buf, int len)
Definition: crc.h:43
+ Here is the call graph for this function:

Member Data Documentation

◆ crc8

crc8_engine leansdr::s2_framer::crc8
private

Definition at line 2505 of file dvbs2.h.

◆ in

pipereader<tspacket> leansdr::s2_framer::in
private

Definition at line 2503 of file dvbs2.h.

◆ nremain

int leansdr::s2_framer::nremain
private

Definition at line 2506 of file dvbs2.h.

◆ out

pipewriter<bbframe> leansdr::s2_framer::out
private

Definition at line 2504 of file dvbs2.h.

◆ pls

s2_pls leansdr::s2_framer::pls

Definition at line 2433 of file dvbs2.h.

◆ rembuf

uint8_t leansdr::s2_framer::rembuf[tspacket::SIZE]
private

Definition at line 2507 of file dvbs2.h.

◆ remcrc

uint8_t leansdr::s2_framer::remcrc
private

Definition at line 2508 of file dvbs2.h.

◆ rolloff_code

uint8_t leansdr::s2_framer::rolloff_code

Definition at line 2432 of file dvbs2.h.


The documentation for this struct was generated from the following file: