OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 CHROME_BROWSER_MEDIA_WEBRTC_RTP_DUMP_HANDLER_H_ | |
6 #define CHROME_BROWSER_MEDIA_WEBRTC_RTP_DUMP_HANDLER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback.h" | |
10 #include "base/files/file_path.h" | |
11 | |
12 namespace base { | |
13 class FilePath; | |
14 } // namespace base | |
15 | |
16 class WebRtcRtpDumpWriter; | |
17 | |
18 // WebRtcRtpDumpHandler handles operations regarding the WebRTC RTP dump: | |
19 // - Starts or stops the RTP dumping on behalf of the client. | |
20 // - Stops the RTP dumping when the max dump file size is reached. | |
21 // - Writes the dump file. | |
22 // - Provides the dump file to the client code to be uploaded when | |
23 // ReleaseRtpDump is called. | |
24 // All public methods should be called on the IO thread. | |
25 class WebRtcRtpDumpHandler { | |
26 public: | |
27 struct PacketType { | |
28 bool incoming; | |
29 bool outgoing; | |
30 }; | |
31 | |
32 typedef base::Callback<void(bool success, const base::FilePath& dump_file)> | |
33 ReleaseDumpCallback; | |
34 | |
35 // The caller must make sure |dump_dir| exists. RTP dump files are saved under | |
36 // |dump_dir| as "rtpdump_XXXXX.gz". | |
Henrik Grunell
2014/05/07 09:38:19
Explain in the comment what XXXXX is. How is filen
| |
37 explicit WebRtcRtpDumpHandler(const base::FilePath& dump_dir); | |
38 virtual ~WebRtcRtpDumpHandler(); | |
39 | |
40 // Incoming/outgoing dumping can be started separately. Returns true if called | |
41 // in a valid state, i.e. dumping has not been started for any type specified | |
42 // in |type|. | |
43 bool StartDump(const PacketType& type); | |
44 | |
45 // Incoming/outgoing dumping can be stopped separately. Returns true if called | |
46 // in a valid state, i.e. dumping has been started and not stopped for any | |
47 // type specified in |type|. | |
48 bool StopDump(const PacketType& type); | |
49 | |
50 // It should only be called when both incoming and outgoing dumping has been | |
51 // stopped. Returns true if it's called in a valid state and the callback will | |
52 // be called when it finishes writing the dump file. | |
53 // If the method returns true, the caller will own the dump file and should | |
54 // clean it up from the disk when suitable. Otherwise, the dump will be | |
55 // deleted before WebRtcRtpDumpHandler goes away. | |
56 bool ReleaseDump(const ReleaseDumpCallback& callback); | |
57 | |
58 virtual void OnRtpPacket(const uint8* packet, size_t length, bool incoming); | |
Henrik Grunell
2014/05/07 09:38:19
Add comment.
| |
59 | |
60 private: | |
61 // State transitions: | |
62 // initial --> STATE_NONE | |
63 // StartDump --> STATE_STARTED | |
64 // StopDump --> STATE_STOPPED | |
65 // ReleaseDump --> STATE_NONE | |
66 enum State { | |
67 STATE_NONE, | |
68 STATE_STARTED, | |
69 STATE_STOPPED | |
70 }; | |
71 | |
72 void OnMaxDumpSizeReached(); | |
Henrik Grunell
2014/05/07 09:38:19
My guess before looking at the implementation is t
| |
73 void OnWriterFlushDone(const ReleaseDumpCallback& callback, | |
74 bool succeeded); | |
75 | |
76 base::FilePath dump_dir_; | |
Henrik Grunell
2014/05/07 09:38:19
Comment all member variables.
| |
77 base::FilePath dump_path_; | |
78 State incoming_state_; | |
79 State outgoing_state_; | |
80 scoped_ptr<WebRtcRtpDumpWriter> dump_writer_; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(WebRtcRtpDumpHandler); | |
83 }; | |
84 | |
85 #endif // CHROME_BROWSER_MEDIA_WEBRTC_RTP_DUMP_HANDLER_H_ | |
OLD | NEW |