aja-video / libajantv2

Open-source library for AJA Video Systems desktop IO cards.
MIT License
22 stars 16 forks source link

Feature/move semantics ajaancillarylist #37

Closed zerodefect closed 3 weeks ago

zerodefect commented 3 weeks ago

The AJAAncillaryList encapsulates the following data types:

    AJAAncillaryDataList    m_ancList;      ///< @brief My packet list
    bool                    m_rcvMultiRTP;  ///< @brief True: Rcv 1 RTP pkt per Anc pkt;  False: Rcv 1 RTP pkt for all Anc pkts
    bool                    m_xmitMultiRTP; ///< @brief True: Xmit 1 RTP pkt per Anc pkt;  False: Xmit 1 RTP pkt for all Anc pkts
    bool                    m_ignoreCS;     ///< @brief True: ignore checksum errors;  False: don't ignore CS errors

...and AJAAncillaryDataList is a typedef for:

typedef std::vector <AJAAncillaryData*>         AJAAncillaryDataList;

which means the underlying types already have support for move semantics with a C++11 compiler.

I have the following function in my code:

AJAAncillaryList content_processor_aja_sdi_output::get_vanc_data_to_insert(...)
{
    AJAAncillaryList pkts;
    // ...
    return pkts;
}

Every time this function is called, instead of moving the packets, the packets get copied (allocation/deallocation per ancillary type) when they can merely be moved.

Changes tested within a linux environment - not tested on Windows. Need to be careful of any memory leaks, but I think I've covered all bases.