• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef TEST_PC_E2E_ANALYZER_VIDEO_ENCODED_IMAGE_DATA_INJECTOR_H_
12 #define TEST_PC_E2E_ANALYZER_VIDEO_ENCODED_IMAGE_DATA_INJECTOR_H_
13 
14 #include <cstdint>
15 #include <utility>
16 
17 #include "absl/types/optional.h"
18 #include "api/video/encoded_image.h"
19 
20 namespace webrtc {
21 namespace webrtc_pc_e2e {
22 
23 // Injects frame id into EncodedImage on encoder side
24 class EncodedImageDataInjector {
25  public:
26   virtual ~EncodedImageDataInjector() = default;
27 
28   // Return encoded image with specified `id` and `discard` flag injected into
29   // its payload. `discard` flag mean does analyzing decoder should discard this
30   // encoded image because it belongs to unnecessary simulcast stream or spatial
31   // layer.
32   virtual EncodedImage InjectData(uint16_t id,
33                                   bool discard,
34                                   const EncodedImage& source) = 0;
35 };
36 
37 struct EncodedImageExtractionResult {
38   absl::optional<uint16_t> id;
39   EncodedImage image;
40   // Is true if encoded image should be discarded. It is used to filter out
41   // unnecessary spatial layers and simulcast streams.
42   bool discard;
43 };
44 
45 // Extracts frame id from EncodedImage on decoder side.
46 class EncodedImageDataExtractor {
47  public:
48   virtual ~EncodedImageDataExtractor() = default;
49 
50   // Invoked by framework before any image will come to the extractor.
51   // `expected_receivers_count` is the expected amount of receivers for each
52   // encoded image.
53   virtual void Start(int expected_receivers_count) = 0;
54 
55   // Invoked by framework when it is required to add one more receiver for
56   // frames. Will be invoked before that receiver will start receive data.
57   virtual void AddParticipantInCall() = 0;
58 
59   // Invoked by framework when it is required to remove receiver for frames.
60   // Will be invoked after that receiver will stop receiving data.
61   virtual void RemoveParticipantInCall() = 0;
62 
63   // Returns encoded image id, extracted from payload and also encoded image
64   // with its original payload. For concatenated spatial layers it should be the
65   // same id.
66   virtual EncodedImageExtractionResult ExtractData(
67       const EncodedImage& source) = 0;
68 };
69 
70 class EncodedImageDataPropagator : public EncodedImageDataInjector,
71                                    public EncodedImageDataExtractor {
72  public:
73   ~EncodedImageDataPropagator() override = default;
74 };
75 
76 }  // namespace webrtc_pc_e2e
77 }  // namespace webrtc
78 
79 #endif  // TEST_PC_E2E_ANALYZER_VIDEO_ENCODED_IMAGE_DATA_INJECTOR_H_
80