Home | History | Annotate | Download | only in webm
      1 // Copyright (c) 2013 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_WEBM_WEBM_VIDEO_CLIENT_H_
      6 #define MEDIA_WEBM_WEBM_VIDEO_CLIENT_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "media/base/media_log.h"
     12 #include "media/webm/webm_parser.h"
     13 
     14 namespace media {
     15 class VideoDecoderConfig;
     16 
     17 // Helper class used to parse a Video element inside a TrackEntry element.
     18 class WebMVideoClient : public WebMParserClient {
     19  public:
     20   explicit WebMVideoClient(const LogCB& log_cb);
     21   virtual ~WebMVideoClient();
     22 
     23   // Reset this object's state so it can process a new video track element.
     24   void Reset();
     25 
     26   // Initialize |config| with the data in |codec_id|, |codec_private|,
     27   // |is_encrypted| and the fields parsed from the last video track element this
     28   // object was used to parse.
     29   // Returns true if |config| was successfully initialized.
     30   // Returns false if there was unexpected values in the provided parameters or
     31   // video track element fields. The contents of |config| are undefined in this
     32   // case and should not be relied upon.
     33   bool InitializeConfig(const std::string& codec_id,
     34                         const std::vector<uint8>& codec_private,
     35                         bool is_encrypted,
     36                         VideoDecoderConfig* config);
     37 
     38  private:
     39   // WebMParserClient implementation.
     40   virtual bool OnUInt(int id, int64 val) OVERRIDE;
     41   virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE;
     42   virtual bool OnFloat(int id, double val) OVERRIDE;
     43 
     44   LogCB log_cb_;
     45   int64 pixel_width_;
     46   int64 pixel_height_;
     47   int64 crop_bottom_;
     48   int64 crop_top_;
     49   int64 crop_left_;
     50   int64 crop_right_;
     51   int64 display_width_;
     52   int64 display_height_;
     53   int64 display_unit_;
     54   int64 alpha_mode_;
     55 
     56   DISALLOW_COPY_AND_ASSIGN(WebMVideoClient);
     57 };
     58 
     59 }  // namespace media
     60 
     61 #endif  // MEDIA_WEBM_WEBM_VIDEO_CLIENT_H_
     62