LCOV - code coverage report
Current view: top level - media/server/main/include - DataReaderV1.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.7 % 12 11
Test Date: 2025-02-18 13:13:53 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2022 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #ifndef FIREBOLT_RIALTO_SERVER_DATA_READERV1_H_
      21              : #define FIREBOLT_RIALTO_SERVER_DATA_READERV1_H_
      22              : 
      23              : #include "IDataReader.h"
      24              : #include "MediaCommon.h"
      25              : #include <algorithm>
      26              : #include <cstdint>
      27              : #include <memory>
      28              : #include <utility>
      29              : #include <vector>
      30              : 
      31              : namespace firebolt::rialto::server
      32              : {
      33              : class DataReaderV1 : public IDataReader
      34              : {
      35              :     struct MetadataV1
      36              :     {
      37              :         std::uint32_t offset;        /* Offset of first byte of sample in CM buffer */
      38              :         std::uint32_t length;        /* Number of bytes in sample */
      39              :         std::int64_t timePosition;   /* Position in stream in nanoseconds */
      40              :         std::int64_t sampleDuration; /* Frame/sample duration in nanoseconds */
      41              :         std::uint32_t streamId;      /* stream id (unique ID for ES, as defined in attachSource()) */
      42              :         std::uint32_t extraDataSize; /* extraData size */
      43              :         std::uint8_t extraData[32];  /* buffer containing extradata */
      44              :         std::uint32_t mediaKeysId;   /* Identifier of MediaKeys instance to use for decryption. If 0 use any CDM
      45              :                                         containing the MKS ID */
      46              :         std::uint32_t mediaKeySessionIdentifierOffset; /* Offset to the location of the MediaKeySessionIdentifier */
      47              :         std::uint32_t mediaKeySessionIdentifierLength; /* Length of the MediaKeySessionIdentifier */
      48              :         std::uint32_t initVectorOffset;                /* Offset to the location of the initialization vector */
      49              :         std::uint32_t initVectorLength;                /* Length of initialization vector */
      50              :         std::uint32_t subSampleInfoOffset;             /* Offset to the location of the sub sample info table */
      51              :         std::uint32_t subSampleInfoLen;                /* Length of sub-sample Info table */
      52              :         std::uint32_t initWithLast15;
      53              :         std::uint32_t extra1; /* Samples per second for audio; Video width in pixels for video */
      54              :         std::uint32_t extra2; /* Number of channels for audio; Video height in pixels for video */
      55              :     };
      56              : 
      57              : public:
      58              :     DataReaderV1(const MediaSourceType &mediaSourceType, std::uint8_t *buffer, std::uint32_t metadataOffset,
      59              :                  std::uint32_t numFrames);
      60            5 :     ~DataReaderV1() override = default;
      61              : 
      62              :     IMediaPipeline::MediaSegmentVector readData() const override;
      63              : 
      64              : private:
      65              :     std::vector<MetadataV1> readMetadata() const;
      66              : 
      67              : private:
      68              :     MediaSourceType m_mediaSourceType;
      69              :     std::uint8_t *m_buffer;
      70              :     std::uint32_t m_metadataOffset;
      71              :     std::uint32_t m_numFrames;
      72              : 
      73            2 :     template <typename SegmentType> std::unique_ptr<SegmentType> createSegment(const MetadataV1 &metadata) const
      74              :     {
      75            0 :         std::unique_ptr<SegmentType> mediaSegment{std::make_unique<SegmentType>(0, metadata.timePosition,
      76            2 :                                                                                 metadata.sampleDuration,
      77            2 :                                                                                 metadata.extra1, metadata.extra2)};
      78            2 :         mediaSegment->setData(metadata.length, m_buffer + metadata.offset);
      79            2 :         std::vector<std::uint8_t> extraDataVec;
      80            2 :         std::copy(&metadata.extraData[0], &metadata.extraData[metadata.extraDataSize], std::back_inserter(extraDataVec));
      81            2 :         mediaSegment->setExtraData(extraDataVec);
      82            2 :         mediaSegment->setEncrypted(false); // temporary, only clear content playback should be supported now
      83            4 :         return mediaSegment;
      84            2 :     }
      85              : };
      86              : } // namespace firebolt::rialto::server
      87              : 
      88              : #endif // FIREBOLT_RIALTO_SERVER_DATA_READERV1_H_
        

Generated by: LCOV version 2.0-1