1/*
2 * Copyright 2005, Jérôme Duval. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers)
6 */
7
8#ifndef SCOPEVIEW_H
9#define SCOPEVIEW_H
10
11#include <Bitmap.h>
12#include <View.h>
13#include <MediaTrack.h>
14
15
16class ScopeView : public BView
17{
18public:
19	ScopeView(BRect rect, uint32 resizeFlags);
20	~ScopeView();
21	void AttachedToWindow();
22	void DetachedFromWindow();
23	void Draw(BRect updateRect);
24	void SetMainTime(bigtime_t timestamp);
25	void SetLeftTime(bigtime_t timestamp);
26	void SetRightTime(bigtime_t timestamp);
27	void SetTotalTime(bigtime_t timestamp, bool reset);
28	void RenderTrack(BMediaTrack *track, const media_format &format);
29	void CancelRendering();
30	virtual void FrameResized(float width, float height);
31	virtual void MouseDown(BPoint position);
32private:
33	void Run();
34	void Quit();
35	static int32 RenderLaunch(void *data);
36	void RenderLoop();
37	template<typename T, typename U> void ComputeRendering();
38	void RenderBitmap();
39	void InitBitmap();
40
41	thread_id fThreadId;
42	BBitmap *fBitmap;
43	BView *fBitmapView;
44	sem_id fRenderSem;
45	bool fIsRendering;
46	BMediaTrack *fMediaTrack;
47	media_format fPlayFormat;
48
49	bigtime_t fMainTime;
50	bigtime_t fRightTime;
51	bigtime_t fLeftTime;
52	bigtime_t fTotalTime;
53	int32 fPreview[20000];
54	float fHeight;
55};
56
57#endif	/* SCOPEVIEW_H */
58