1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_BLINK_SMOOTHNESS_HELPER_H_ 6 #define MEDIA_BLINK_SMOOTHNESS_HELPER_H_ 7 8 #include <memory> 9 10 #include "media/base/buffering_state.h" 11 #include "media/base/pipeline_status.h" 12 #include "media/blink/media_blink_export.h" 13 #include "media/learning/common/labelled_example.h" 14 15 namespace media { 16 17 namespace learning { 18 class LearningTaskController; 19 } 20 21 // Helper class to construct learning observations about the smoothness of a 22 // video playback. Currently measures the worst-case frame drop ratio observed 23 // among fixed-length segments. 24 class MEDIA_BLINK_EXPORT SmoothnessHelper { 25 public: 26 // Callback that provides the number of dropped / decoded frames since some 27 // point in the past. We assume that these values are comparable during 28 // playback, so that we can compute deltas. 29 class Client { 30 public: ~Client()31 virtual ~Client() {} 32 33 virtual unsigned DecodedFrameCount() const = 0; 34 virtual unsigned DroppedFrameCount() const = 0; 35 }; 36 37 virtual ~SmoothnessHelper(); 38 39 // Return the features that we were constructed with. features()40 const learning::FeatureVector& features() const { return features_; } 41 42 // Notify us that an NNR has occurred. 43 virtual void NotifyNNR() = 0; 44 45 // |features| are the features that we'll use for any labelled examples that 46 // we create. They should be features that could be captured at the time a 47 // prediction would be needed. 48 static std::unique_ptr<SmoothnessHelper> Create( 49 std::unique_ptr<learning::LearningTaskController> bad_controller, 50 std::unique_ptr<learning::LearningTaskController> nnr_controller, 51 const learning::FeatureVector& features, 52 Client* player); 53 54 // We split playbacks up into |kSegmentSize| units, and record the worst 55 // dropped frame ratio over all segments of a playback. A playback is not 56 // recorded if it doesn't contain at least one full segment. 57 static base::TimeDelta SegmentSizeForTesting(); 58 59 protected: 60 SmoothnessHelper(const learning::FeatureVector& features); 61 62 learning::FeatureVector features_; 63 }; 64 65 } // namespace media 66 67 #endif // MEDIA_BLINK_SMOOTHNESS_HELPER_H_ 68