Class

VipsSource

Description [src]

class Vips.Source : Vips.Connection
{
  gboolean decode,
  gboolean have_tested_seek,
  gboolean is_pipe,
  gint64 read_position,
  gint64 length
}

A VipsSource provides a unified interface for reading, seeking, and mapping data, regardless of the underlying source type.

This source can originate from something like a socket, file or memory area.

During the header phase, we save data from unseekable sources in a buffer so readers can rewind and read again. We don’t buffer data during the decode stage.

Hierarchy

hierarchy this VipsSource ancestor_0 VipsConnection ancestor_0--this ancestor_1 VipsObject ancestor_1--ancestor_0 ancestor_2 GObject ancestor_2--ancestor_1

Descendants

Constructors

vips_source_new_from_blob

Create a source attached to an area of memory.

vips_source_new_from_descriptor

Create an source attached to a file descriptor. descriptor is closed with close() when source is finalized.

vips_source_new_from_file

Create a source attached to a file.

vips_source_new_from_memory

Create a source attached to an area of memory.

vips_source_new_from_options

Create a source from an option string.

vips_source_new_from_target

Create a source from a temp target that has been written to.

Functions

vips_source_g_input_stream_new

Create a VipsSourceGInputStream which wraps stream.

Instance methods

vips_source_decode

Signal the end of header read and the start of the pixel decode phase. After this, you can no longer seek on this source.

vips_source_is_file

Test if this source is a simple file with support for seek. Named pipes, for example, will fail this test. If TRUE, you can use vips_connection_filename() to find the filename.

vips_source_is_mappable

Some sources can be efficiently mapped into memory. You can still use vips_source_map() if this function returns FALSE, but it will be slow.

vips_source_length

Return the length in bytes of the source. Unseekable sources, for example pipes, will have to be read entirely into memory before the length can be found, so this operation can take a long time.

vips_source_map

Map the source entirely into memory and return a pointer to the start. If length is non-NULL, the source size is written to it.

vips_source_map_blob

Just like vips_source_map(), but return a VipsBlob containing the pointer. source will stay alive as long as the result is alive.

vips_source_minimise

Minimise the source. As many resources as can be safely removed are removed. Use vips_source_unminimise() to restore the source if you wish to use it again.

vips_source_read

Read up to length bytes from source and store the bytes in buffer. Return the number of bytes actually read. If all bytes have been read from the file, return 0.

vips_source_rewind

Rewind the source to the start.

vips_source_seek

Move the file read position. You can’t call this after pixel decode starts. The arguments are exactly as lseek(2).

vips_source_sniff

Return a pointer to the first few bytes of the file. If the file is too short, return NULL.

vips_source_sniff_at_most

Attempt to sniff at most length bytes from the start of the source. A pointer to the bytes is returned in data. The number of bytes actually read is returned — it may be less than length if the file is shorter than length. A negative number indicates a read error.

vips_source_unminimise

Restore the source after minimisation. This is called at the start of every source method, so loaders should not usually need this.

Methods inherited from VipsConnection (2)
vips_connection_filename
No description available.

vips_connection_nick
No description available.

Methods inherited from VipsObject (27)

Please see VipsObject for a full list of methods.

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

Vips.Source:blob
No description available.

Properties inherited from VipsConnection (2)
Vips.Connection:descriptor
No description available.

Vips.Connection:filename
No description available.

Properties inherited from VipsObject (2)
Vips.Object:description
No description available.

Vips.Object:nickname
No description available.

Signals

Signals inherited from VipsObject (4)
VipsObject::close

The ::close signal is emitted once during object close. The object is dying and may not work.

VipsObject::postbuild

The ::postbuild signal is emitted once just after successful object construction. Return non-zero to cause object construction to fail.

VipsObject::postclose

The ::postclose signal is emitted once after object close. The object pointer is still valid, but nothing else.

VipsObject::preclose

The ::preclose signal is emitted once just before object close starts. The object is still alive.

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct VipsSourceClass {
  VipsConnectionClass parent_class;
  gint64 (* read) (
    VipsSource* source,
    void* buffer,
    size_t length
  );
  gint64 (* seek) (
    VipsSource* source,
    gint64 offset,
    int whence
  );
  
}

No description available.

Class members
parent_class: VipsConnectionClass

No description available.

read: gint64 (* read) ( VipsSource* source, void* buffer, size_t length )

No description available.

seek: gint64 (* seek) ( VipsSource* source, gint64 offset, int whence )

No description available.

Virtual methods

Vips.SourceClass.read

Read up to length bytes from source and store the bytes in buffer. Return the number of bytes actually read. If all bytes have been read from the file, return 0.

Vips.SourceClass.seek

Move the file read position. You can’t call this after pixel decode starts. The arguments are exactly as lseek(2).