| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_BASE_DECODER_H_ | 5 #ifndef REMOTING_BASE_DECODER_H_ |
| 6 #define REMOTING_BASE_DECODER_H_ | 6 #define REMOTING_BASE_DECODER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "remoting/base/protocol/chromotocol.pb.h" | 14 #include "remoting/base/protocol/chromotocol.pb.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 // TODO(hclam): Merge this with the one in remoting/host/encoder.h. | 18 // TODO(hclam): Merge this with the one in remoting/host/encoder.h. |
| 19 typedef std::vector<gfx::Rect> UpdatedRects; | 19 typedef std::vector<gfx::Rect> UpdatedRects; |
| 20 | 20 |
| 21 // Defines the behavior of a decoder for decoding images received from the | 21 // Defines the behavior of a decoder for decoding images received from the |
| 22 // host. | 22 // host. |
| 23 // | 23 // |
| 24 // Sequence of actions with a decoder is as follows: | 24 // Sequence of actions with a decoder is as follows: |
| 25 // | 25 // |
| 26 // 1. BeginDecode(PartialDecodeDone, DecodeDone, VideoFrame) | 26 // 1. BeginDecode(PartialDecodeDone, DecodeDone, VideoFrame) |
| 27 // 2. PartialDecode(ChromotingHostMessage) | 27 // 2. PartialDecode(HostMessage) |
| 28 // ... | 28 // ... |
| 29 // 3. EndDecode() | 29 // 3. EndDecode() |
| 30 // | 30 // |
| 31 // The decoder will reply with: | 31 // The decoder will reply with: |
| 32 // 1. PartialDecodeDone(VideoFrame, UpdatedRects) | 32 // 1. PartialDecodeDone(VideoFrame, UpdatedRects) |
| 33 // ... | 33 // ... |
| 34 // 2. DecodeDone(VideoFrame) | 34 // 2. DecodeDone(VideoFrame) |
| 35 // | 35 // |
| 36 // The format of VideoFrame is a contract between the object that creates the | 36 // The format of VideoFrame is a contract between the object that creates the |
| 37 // decoder (most likely the renderer) and the decoder. | 37 // decoder (most likely the renderer) and the decoder. |
| 38 class Decoder { | 38 class Decoder { |
| 39 public: | 39 public: |
| 40 | 40 |
| 41 virtual ~Decoder() { | 41 virtual ~Decoder() { |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Tell the decoder to use |frame| as a target to write the decoded image | 44 // Tell the decoder to use |frame| as a target to write the decoded image |
| 45 // for the coming update stream. | 45 // for the coming update stream. |
| 46 // If decode is partially done and |frame| can be read, |partial_decode_done| | 46 // If decode is partially done and |frame| can be read, |partial_decode_done| |
| 47 // is called and |update_rects| contains the updated regions. | 47 // is called and |update_rects| contains the updated regions. |
| 48 // If decode is completed |decode_done| is called. | 48 // If decode is completed |decode_done| is called. |
| 49 // Return true if the decoder can writes output to |frame| and accept | 49 // Return true if the decoder can writes output to |frame| and accept |
| 50 // the codec format. | 50 // the codec format. |
| 51 // TODO(hclam): Provide more information when calling this function. | 51 // TODO(hclam): Provide more information when calling this function. |
| 52 virtual bool BeginDecode(scoped_refptr<media::VideoFrame> frame, | 52 virtual bool BeginDecode(scoped_refptr<media::VideoFrame> frame, |
| 53 UpdatedRects* updated_rects, | 53 UpdatedRects* updated_rects, |
| 54 Task* partial_decode_done, | 54 Task* partial_decode_done, |
| 55 Task* decode_done) = 0; | 55 Task* decode_done) = 0; |
| 56 | 56 |
| 57 // Give a ChromotingHostMessage that contains the update stream packet that | 57 // Give a HostMessage that contains the update stream packet that contains |
| 58 // contains the encoded data to the decoder. | 58 // the encoded data to the decoder. |
| 59 // The decoder will own |message| and is responsible for deleting it. | 59 // The decoder will own |message| and is responsible for deleting it. |
| 60 // | 60 // |
| 61 // If the decoder has written something into |frame|, | 61 // If the decoder has written something into |frame|, |
| 62 // |partial_decode_done_| is called with |frame| and updated regions. | 62 // |partial_decode_done_| is called with |frame| and updated regions. |
| 63 // Return true if the decoder can accept |message| and decode it. | 63 // Return true if the decoder can accept |message| and decode it. |
| 64 // | 64 // |
| 65 // ChromotingHostMessage returned by this method will contain a | 65 // HostMessage returned by this method will contain a |
| 66 // UpdateStreamPacketMessage. | 66 // UpdateStreamPacketMessage. |
| 67 // This message will contain either: | 67 // This message will contain either: |
| 68 // 1. UpdateStreamBeginRect | 68 // 1. UpdateStreamBeginRect |
| 69 // 2. UpdateStreamRectData | 69 // 2. UpdateStreamRectData |
| 70 // 3. UpdateStreamEndRect | 70 // 3. UpdateStreamEndRect |
| 71 // | 71 // |
| 72 // See remoting/base/protocol/chromotocol.proto for more information about | 72 // See remoting/base/protocol/chromotocol.proto for more information about |
| 73 // these messages. | 73 // these messages. |
| 74 virtual bool PartialDecode(ChromotingHostMessage* message) = 0; | 74 virtual bool PartialDecode(HostMessage* message) = 0; |
| 75 | 75 |
| 76 // Notify the decoder that we have received the last update stream packet. | 76 // Notify the decoder that we have received the last update stream packet. |
| 77 // If the decoding of the update stream has completed |decode_done_| is | 77 // If the decoding of the update stream has completed |decode_done_| is |
| 78 // called with |frame|. | 78 // called with |frame|. |
| 79 // If the update stream is not received fully and this method is called the | 79 // If the update stream is not received fully and this method is called the |
| 80 // decoder should also call |decode_done_| as soon as possible. | 80 // decoder should also call |decode_done_| as soon as possible. |
| 81 virtual void EndDecode() = 0; | 81 virtual void EndDecode() = 0; |
| 82 | 82 |
| 83 protected: | 83 protected: |
| 84 // Every decoder will have two internal states because there are three | 84 // Every decoder will have two internal states because there are three |
| (...skipping 20 matching lines...) Expand all Loading... |
| 105 // The decode remains in this state if UpdateStreamRectData is received. | 105 // The decode remains in this state if UpdateStreamRectData is received. |
| 106 // The decoder will transit to kWaitingForBeginRect if UpdateStreamEndRect | 106 // The decoder will transit to kWaitingForBeginRect if UpdateStreamEndRect |
| 107 // is received. | 107 // is received. |
| 108 kWaitingForRectData, | 108 kWaitingForRectData, |
| 109 }; | 109 }; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace remoting | 112 } // namespace remoting |
| 113 | 113 |
| 114 #endif // REMOTING_BASE_DECODER_H_ | 114 #endif // REMOTING_BASE_DECODER_H_ |
| OLD | NEW |